// Create wrapper object for each primitive type
Boolean sampleBoolean = new Boolean(true);
Byte sampleByte = new Byte((byte)245);
Character sampleChar = new Character('Y');
Short sampleShort = new Short((short)245);
Integer sampleInt = new Integer(245);
Long sampleLong = new Long(245L);
Float sampleFloat = new Float(245F);
Double sampleDouble = new Double(24.5D);
// Retrieving the value in a wrapper object
boolean bool = sampleBoolean.booleanValue();
byte b = sampleByte.byteValue();
char c = sampleChar.charValue();
short s = sampleShort.shortValue();
int i = sampleInt.intValue();
long l = sampleLong.longValue();
float f = sampleFloat.floatValue();
double d = sampleDouble.doubleValue();
Monday, June 22, 2009
How to Wrape a Primitive Type in a Wrapper Object
10:57 PM
Posted by
Techsavy
Subscribe to:
Post Comments (Atom)
1 comments:
http://www.behindjava.com/2014/06/primitive-and-wrapper-classes-in-java.html
Post a Comment