Results 1 to 3 of 3

Thread: Error meaning

  1. #1
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

    Default Error meaning

    java.lang.NullPointerException

    What does this error mean?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,225
    Rep Power
    20

    Default Re: Error meaning

    The JVM is attempting to call a method/access an attribute on a reference that is null.
    Java Code:
    public SomeClass {
       private String someAttribute;
       public SomeClass () {
          System.out.println(someAttribute.length());
       }
    }
    In the above the someAttribute reference is never initialised to point to a String object, so it is defaulted to null.
    The attempt in the constructor to access the length() method will result in a null pointer exception.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    Johanis is offline Senior Member
    Join Date
    Oct 2010
    Posts
    139
    Rep Power
    0

Similar Threads

  1. What is the meaning of the char(0x00)?
    By Lionlev in forum New To Java
    Replies: 8
    Last Post: 06-10-2012, 01:28 PM
  2. The meaning of replaceAll
    By herolua in forum New To Java
    Replies: 4
    Last Post: 10-07-2011, 06:18 AM
  3. Phrase Meaning
    By griddle in forum New To Java
    Replies: 1
    Last Post: 04-25-2011, 07:45 PM
  4. for loop meaning
    By ahmakki in forum New To Java
    Replies: 3
    Last Post: 04-12-2010, 02:06 AM
  5. Exception:Meaning
    By tiger100plus in forum New To Java
    Replies: 2
    Last Post: 11-27-2008, 08:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •