Thursday, March 12, 2009

Can you compare if null is equal to null? i.e.

Question :Can you compare if null is equal to null? i.e.
String str = null;
String str1 = null;
if(str == str1)
SOP("true");
(CoreJava)

Answer :Yes, And its going to be true as the objects have not been allocated any
memory location.

No comments: