So, a short story. The professor asked this question in the classroom as a discussion starter. Beyond the obvious
B = new SomeClass("B"); // But B can be null, can can be new SomeClass("A"); A = new SomeClass("A"); A==B
doesn't guarantee no NPE when comparing, what are the reasons for using B == A instead of A == B?
Where A and B are of the same type, and it is language independent. So you can assume A.equals (B) for Java, or equivalent syntax in C or C ++, etc.
And no, this is not homework.
java c # programming-languages
Churk
source share