Click here to Skip to main content
16,020,377 members
Home / Discussions / Java
   

Java

 
QuestionHow to compare two classes instances Pin
khurram_shahzad14-Jan-11 15:54
khurram_shahzad14-Jan-11 15:54 
AnswerRe: How to compare two classes instances Pin
Richard MacCutchan15-Jan-11 0:19
mveRichard MacCutchan15-Jan-11 0:19 
GeneralRe: How to compare two classes instances Pin
khurram_shahzad15-Jan-11 3:10
khurram_shahzad15-Jan-11 3:10 
GeneralRe: How to compare two classes instances Pin
Richard MacCutchan15-Jan-11 4:39
mveRichard MacCutchan15-Jan-11 4:39 
GeneralRe: How to compare two classes instances Pin
Cedric Moonen16-Jan-11 21:01
Cedric Moonen16-Jan-11 21:01 
GeneralRe: How to compare two classes instances Pin
Richard MacCutchan17-Jan-11 0:24
mveRichard MacCutchan17-Jan-11 0:24 
GeneralRe: How to compare two classes instances Pin
khurram_shahzad17-Jan-11 3:45
khurram_shahzad17-Jan-11 3:45 
AnswerRe: How to compare two classes instances Pin
Cedric Moonen16-Jan-11 20:59
Cedric Moonen16-Jan-11 20:59 
khurram_shahzad wrote:
and i want to compare there two different instances then how ??


Your question is not really clear.

There's a difference between having the same instance and having two different instances which are the same. In the first case, you want to verify if you are talking about the same instance. That's what you do in the code sample you posted: you check wether currentNode is the same object as toSearch.
In the second case, you want to verify that two instances contain the same thing but they are most of the time two different objects.

In your case, from what I saw in your code sample, you want to verify whether you are talking about the same object. Thus, it is fine to write it the way you did and it will work fine (in fact, when you use the == operator with objects, it will compare if the adresses of the two objects are the same, thus return true if the two pointers point to the same class instance).
Cédric Moonen
Software developer

Charting control [v3.0]
OpenGL game tutorial in C++

GeneralRe: How to compare two classes instances Pin
khurram_shahzad17-Jan-11 3:47
khurram_shahzad17-Jan-11 3:47 
Questionwhich simulator/editor is good for JAVA Pin
aesthetic.crazy13-Jan-11 11:11
aesthetic.crazy13-Jan-11 11:11 
AnswerRe: which simulator/editor is good for JAVA Pin
RaviRanjanKr13-Jan-11 21:16
professionalRaviRanjanKr13-Jan-11 21:16 
AnswerRe: which simulator/editor is good for JAVA Pin
Richard MacCutchan13-Jan-11 22:15
mveRichard MacCutchan13-Jan-11 22:15 
AnswerRe: which simulator/editor is good for JAVA Pin
TorstenH.14-Jan-11 0:03
TorstenH.14-Jan-11 0:03 
GeneralRe: which simulator/editor is good for JAVA Pin
Richard MacCutchan14-Jan-11 0:28
mveRichard MacCutchan14-Jan-11 0:28 
AnswerRe: which simulator/editor is good for JAVA Pin
aesthetic.crazy14-Jan-11 12:59
aesthetic.crazy14-Jan-11 12:59 
GeneralRe: which simulator/editor is good for JAVA Pin
aesthetic.crazy14-Jan-11 13:00
aesthetic.crazy14-Jan-11 13:00 
GeneralRe: which simulator/editor is good for JAVA Pin
Richard MacCutchan15-Jan-11 0:07
mveRichard MacCutchan15-Jan-11 0:07 
GeneralRe: which simulator/editor is good for JAVA Pin
aesthetic.crazy15-Jan-11 12:09
aesthetic.crazy15-Jan-11 12:09 
GeneralRe: which simulator/editor is good for JAVA Pin
Richard MacCutchan15-Jan-11 21:38
mveRichard MacCutchan15-Jan-11 21:38 
QuestionstartNetworkServer Pin
pancakeleh11-Jan-11 21:11
pancakeleh11-Jan-11 21:11 
AnswerRe: startNetworkServer Pin
Richard MacCutchan11-Jan-11 21:20
mveRichard MacCutchan11-Jan-11 21:20 
AnswerRe: startNetworkServer Pin
TorstenH.11-Jan-11 21:39
TorstenH.11-Jan-11 21:39 
GeneralRe: startNetworkServer [modified] Pin
pancakeleh11-Jan-11 21:49
pancakeleh11-Jan-11 21:49 
GeneralRe: startNetworkServer Pin
TorstenH.12-Jan-11 0:17
TorstenH.12-Jan-11 0:17 
GeneralRe: startNetworkServer Pin
pancakeleh12-Jan-11 19:36
pancakeleh12-Jan-11 19:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.