This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Difference between == and equals() in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Difference between == and equals() in java" Watch "Difference between == and equals() in java" New topic
Author

Difference between == and equals() in java

Praveen palukuri
Ranch Hand

Joined: Feb 10, 2005
Posts: 65
hi,
can u give exact difference between == operator and .equals() in java.

Thank You in advance.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

"==" asks whether two objects are the same physical object -- the same chunk of memory. "equals()" is a method which by default means the same thing, but can be overridden to ask whether two objects are "the same" by some appropriate definition. For example, two String objects are "the same" if they have the same characters in the same order, even if they are two different physical objects. String overrides equals() to mean this.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between == and equals() in java
 
Similar Threads
loop trouble
difference between equals() and == and compareTo()
what is the difference between == and .equals() method????
Overriding equals()
Difference between == and .equals