Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Checking if an object is null

807605Sep 13 2007 — edited Sep 14 2007
Hi

I have an object which shows itself as null but does not equal to null when compared. Her is the sequence

Object obj = x.getXXX();
System.out.println(obj);

if(obj != null){
System.out.println("Executing y.do something");
y.doSomething();
}

Here is the result of this

obj = null;
Executing y.doSomething.

My question is if obj is null it should not enter the loop. Please hel me with this . Any suggestions with regards to this is appreciated.

Thanks
Manoj
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 12 2007
Added on Sep 13 2007
32 comments
618 views