This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Originally posted by Shyam Sunder V R: Hi ieveryone, I was going through teh K& B SCJP exam guide .....In the third chapter(Assignments) the section about Wrapper classes quoted something like this.....
It was said that the output would be same objs equal objs since to save memory two wrapper instances with same primitive always satisfy ==
but when I tried out i got the output as equal objs
can you elucidate why it is so?
P.S : i also tried out this code(since the int range is -128 to 127) the result is same.......
[ August 21, 2008: Message edited by: Shyam Sunder V R ]
Hey, did you read the code properly? You initialised a new object using the keyword new There is a difference between
Now I hope you will get the point when you read the book again.