aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes equals() method in String and wrapper classes.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "equals() method in String and wrapper classes.." Watch "equals() method in String and wrapper classes.." New topic
Author

equals() method in String and wrapper classes..

Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362


the above is used to override an equals() method from some class.

String and wrapper classes have override the equals method in Object class.

did they have identical implementation of method which is shown above....?


SCJP5 and SCWCD1.5
Think Twice Act Wise...
mani vannan
Ranch Hand

Joined: Apr 17, 2006
Posts: 47
Yes, the java.lang.String class has similar implementation as above. Please read the source code of equals() here.


Mani (SCEA 1.4)<br /><a href="http://excusemeworld.com/technical/is-scjp-useful-worth-helps-job/" target="_blank" rel="nofollow"> Is SCJP Useful? Worth? Helps job?</a>
Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362
ok.
what about wrapper classes?

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Wrapper classes also follow a similar syntax. If the type of the argument passed and the value of the argument are the same as the one on which it is called, then the output will be true.

eg
new Integer(10).equals(new Integer(10)); //true
new Integer(10).equals(new Float(10)); //false
new Integer(10).equals(new Integer(20)); //false


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
M Srilatha
Ranch Hand

Joined: Aug 27, 2008
Posts: 137
Here is the implementation of equals() method in Integer:



And other wrapper classes will also have the same kind of implementation.
Hope this helps!


Thanks,<br />Srilatha M
Ganeshkumar cheekati
Ranch Hand

Joined: Oct 13, 2008
Posts: 362
Thanks for everyone...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: equals() method in String and wrapper classes..