Wrapping a Primitive Type in a Wrapper Object: boolean, byte, char, short, int, long, float, double : Data Type Introduction « Data Type « Java Tutorial






public class Main {
  public static void main(String[] argv) throws Exception {
    Boolean refBoolean = new Boolean(true);
    boolean bool = refBoolean.booleanValue();
    
    
    Byte refByte = new Byte((byte) 123);
    byte b = refByte.byteValue();
    
    
    Character refChar = new Character('x');
    char c = refChar.charValue();
    
    
    Short refShort = new Short((short) 123);
    short s = refShort.shortValue();
    
    
    Integer refInt = new Integer(123);
    int i = refInt.intValue();
    
    
    Long refLong = new Long(123L);
    long l = refLong.longValue();
    
    
    Float refFloat = new Float(12.3F);
    float f = refFloat.floatValue();
    
    
    Double refDouble = new Double(12.3D);
    double d = refDouble.doubleValue();
  }
}








2.1.Data Type Introduction
2.1.1.The Primitive Types
2.1.2.Size for Java's Primitive Types
2.1.3.Default values for primitives and references
2.1.4.Literals
2.1.5.Surprise! Java lets you overflow
2.1.6.Wrapping a Primitive Type in a Wrapper Object: boolean, byte, char, short, int, long, float, double
2.1.7.Print the limits of primitive types (e.g. byte, short, int ...) in Java
2.1.8.Get the minimum and maximum value of a primitive data types
2.1.9.Shows default initial values
2.1.10.Primitive utilities
2.1.11.Return primitive type the passed in wrapper type corresponds to