Results 1 to 11 of 11
- 02-11-2013, 09:19 AM #1
Member
- Join Date
- Dec 2012
- Location
- India
- Posts
- 6
- Rep Power
- 0
- 02-11-2013, 11:43 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
What do you think?
This sounds rather like homework.Please do not ask for code as refusal often offends.
- 02-11-2013, 01:28 PM #3
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
You didn't bother to reply to PhHein's response in your first thread, and I see no reason to expect better behavior here.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-11-2013, 04:34 PM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
What is advanced about this question? It is Java 101
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-11-2013, 09:05 PM #5
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
"==" and equals() both compare if the objects reference variables refer to the same instance of an object.
But the equals() method can be over-ridden. For example, an employee class may have an equals method which makes two employee reference variables equal if
their employeeId's are equal. Consider
Employee emp1 = new Employee();
Employee emp2 = new Employee();
emp1.equals(emp2) is true if the employeeId's are equal but emp1==emp2 is not true. So when ever u need to specify a custom condition for equality u can over ride equals() and use it. Do remember that u have to over ride hashcode() when ever equals() is over ridden.
- 02-12-2013, 07:34 AM #6
Member
- Join Date
- Dec 2012
- Location
- India
- Posts
- 6
- Rep Power
- 0
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
Hello priya
thanks for your quick reply.
now i am clear of this topic before that i have bit confuse..
- 02-12-2013, 08:03 AM #7
Member
- Join Date
- Dec 2012
- Location
- India
- Posts
- 6
- Rep Power
- 0
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
Hello all,
you know the answer then only reply to thread,otherwise dont post useless comments on thread.
- 02-12-2013, 08:18 AM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
Most (if not all) of us know the answer to your (elementary) question and you're not the one to decide who is allowed to post a reply or not.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-12-2013, 08:46 AM #9
Member
- Join Date
- Dec 2012
- Location
- India
- Posts
- 6
- Rep Power
- 0
Re: what is the difference b/w "==" and equals() in java ? which one is better to use
i think you are thinking that you are the father of java i am correct
any way no issue thanks for replys this is not correct to communicate out side java discussions..
- 02-12-2013, 08:55 AM #10
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,601
- Blog Entries
- 7
- Rep Power
- 17
- 02-12-2013, 11:00 AM #11
Similar Threads
-
access denied("java.net.SocketPermission" "127.0.0.1:1099" "connect,resolve")
By klspepper in forum New To JavaReplies: 0Last Post: 12-07-2012, 08:29 AM -
Difference between again == "y"; and again.equals("y");
By sandman18and5 in forum New To JavaReplies: 5Last Post: 07-27-2012, 06:35 PM -
What is the difference between an "Entity" and "Value Object"?
By vahini in forum Advanced JavaReplies: 4Last Post: 06-14-2011, 04:59 AM -
Difference b/w "synchronized","synchronize",and "synchronized()"
By Bala_Rugan in forum New To JavaReplies: 1Last Post: 09-08-2010, 04:08 PM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM


4Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks