Null pointer exception...

Hi, I am trying to test for a nullpointer exception but it seems to throw before my intended actions...

System.out.println("block = " + block);//prints out fine.
System.out.println("block.contents = " + block);//prints out.

System.out.println("block.contents.equals(null) = " + block.contents.equals(null));//Null Pointer Exception.

block.contents returns a Vector I thought I could do something like "if(block.contents == null)" or
"if(block.contents.equals(null))"?

Thank you for any input or workaround.

Thanks,
noijet
gen228Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
bobbit31Connect With a Mentor Commented:
shouldn't this be:
System.out.println("block.contents = " + block.contents);//prints out.

if (block.contents == null) should work
0
 
gen228Author Commented:
I have been copying and pasting so much that I missed that !  Thanks bobbit31 !

Thanks again,
noijet.
0
All Courses

From novice to tech pro — start learning today.