Level: Beginner
Focus: Wrapper Classes, Primitive Data Types
Playing With Wrappers Question
Every primitive data type has a corresponding wrapper class. These classes are handy if you need to make the primitive data type into an object. However, it's important to remember that the wrapper classes are not the same as primitive data types and will act differently in certain circumstances.
In the following lines of code I've been playing with wrapper classes. The question is can you figure out what the values of the wrapper objects will be?
Boolean eminem = new Boolean("yes");
Boolean lLCoolJ = new Boolean("true");
Integer mosDef = new Integer(Integer.MAX_VALUE+1);
Long queenLatifah = new Long(Integer.MAX_VALUE+1);
Long iceCube = new Long((long)Integer.MAX_VALUE + 1);
Long jayZ = new Long(iceCube++);
Long kanyeWest = new Long(++iceCube);
Character snoopDogg = new Character("c".replace("c", "d").toCharArray()[0]);
Double theGame = new Double(Double.POSITIVE_INFINITY);
Double common = new Double (Math.round(Double.POSITIVE_INFINITY));
Integer nas = 10444;
Integer trickTrick = 10444;
Boolean lilWayne = (nas == trickTrick);
Boolean bowWow = (nas.equals(trickTrick));
To get the most out of this question try and figure out the answer before coming back to read the solution on the next page.

