Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes similarity between string and wrapper objects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "similarity between string and wrapper objects?" Watch "similarity between string and wrapper objects?" New topic
Author

similarity between string and wrapper objects?

vikram choudhary .
Greenhorn

Joined: Apr 25, 2007
Posts: 7
JVM has constant pool of string objects.that's why
"Java"=="Java" always evaluates to true.
is the same case with wrapper objects?
Integer i=3;
Integer j=3;
i==j ?
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Not for all values.

This is from the Java Language Specification, 5.1.7.

If the value p being boxed is true, false, a byte, a char in the range \u0000 to \u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: similarity between string and wrapper objects?
 
Similar Threads
Casting Problem int to String
Wrappers and primitives comparison:
pass by reference
Wrapper ==
K & B q3 chapter 6. Wrappers