File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

equals n ==

 
usha prithvi
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Please explain the difference between == n equal? n how it works in Strings?

Thankz
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's the value of n?
 
usha prithvi
Ranch Hand
Posts: 31
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry.Itz and. What is the difference between == and equals? how does it work in Strings? Thankz
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a very basic question so I'd better move it to our Java In General (Beginner) forum.
 
Hentay Duke
Ranch Hand
Posts: 198
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is the simple answer. Someone else may give you a more in-depth answer.
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an excellent article that you should read:
Comparison operators: equals() versus ==

Please make the extra effort to write out words such as "and". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
equals() is used to check whether two objects are meaningfully equal & == is used to check whether if two instances are equal.

From K&B book :-

[ When you really need to know if two references are identical, use ==. But when you need to know if the objects themselves (not the references) are equal, use the equals() method. ]

For String & Wrapper classes this equals() method is Overrided, For your own class you need to override the equals if you want to check whether two objects are meaningfully equal.
 
Layne Lund
Ranch Hand
Posts: 3061
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by usha prithvi:
I am sorry.Itz and. What is the difference between == and equals? how does it work in Strings? Thankz


I think the point of the question about "what is n?" means that you need to use proper English. "Itz" isn't a word either. We try to maintain a somewhat professional appearance around here. This is especially important when you ask questions if you really want us to take you seriously. Please avoid l33t and other chat-like abreviations. It usually detracts from the point that you want to make and might even prohibit us from understanding you altogether.

Layne
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic