Null pointer exception...

Posted on 2003-03-20
Medium Priority
Last Modified: 2010-03-31
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

Thank you for any input or workaround.

Question by:gen228
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 18

Accepted Solution

bobbit31 earned 100 total points
ID: 8176338
shouldn't this be:
System.out.println("block.contents = " + block.contents);//prints out.

if (block.contents == null) should work

Author Comment

ID: 8176384
I have been copying and pasting so much that I missed that !  Thanks bobbit31 !

Thanks again,

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question