Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Java Lang Null pointer exception.... what's that?

Java won't display charts, citing error. How do I fix that?

19 Answers

Relevance
  • JohnC
    Lv 5
    1 decade ago
    Favorite Answer

    The error itself is easy to explain, but without a context, it's impossible to tell you where it's happening and why.

    A java.lang.NullPointerException occurs when a Java application or Java applet has been badly coded. Typically, the Java program (and consequently, the programmer) attempted to access the reference or handle to a Java object that did not exist.

    Here's an analogy that may help:

    You have a piece of land on which you intend to build your own house, but you haven't built it yet.

    This is the equivalent of creating (or owning) a Java object reference (also called an address).

    Before you build the house, you accidentally give out your address to people, saying "That's my home address" (even though there's nothing there, not even a sign saying "My House").

    This is the equivalent of wrongly using the Java object reference (or address) without actually having created a Java object within it.

    The postman, your friends and your relatives drive to the address but find nothing there and think it's an error.

    This is the equivalent of getting a NullPointerException.

    If you're seeing the exception when using an existing Java application what displays charts, then the application has been badly coded. If you're getting the exception when writing your own Java code to display charts, I can help you, though you'll need to give me more details including the code snippet that is causing the exception.

    The wrong n' dirty way of quickly solving (or actually suppressing) the exception is to encapsulate the offending code in a try-catch block and handle the catch in some quiet, elegant way.

    The right way of solving the exception is to figure out the line causing the problem, and trace it's source, reason and data.

  • Anonymous
    6 years ago

    This Site Might Help You.

    RE:

    Java Lang Null pointer exception.... what's that?

    Java won't display charts, citing error. How do I fix that?

    Source(s): java lang null pointer exception that: https://knowledge.im/?s=java+lang+null+pointer+exc...
  • Anonymous
    7 years ago

    java.lang.NullPointerExeption is one of the most common Java Exception. This problem can be seen when either developing or running Java-based applications.

    If you are running into this problem while running a particular Java program then my main recommendation is to look from the product support for possible known issues.

    If you are actually developing Java applications then the best approach is to debug and find out the source of the null reference(s) that you are dealing with. Adding proper validation will allow your code to more gracefully handle scenarios leading to null references.

  • 4 years ago

    Minecraft Java.lang.nullpointerexception

  • How do you think about the answers? You can sign in to vote the answer.
  • 4 years ago

    I'm currently using Eclipse LUNA (JAVA EE IDE) and I'm currently doing the prompting guess activity on a Java Basic Course. ERROR MESSAGE: Exception in .........

  • Anonymous
    5 years ago

    Bhggjijjynj

  • 1 decade ago

    Java puts things into the computer memory (the heap) and you can call it with a label (the var name). null pointer exception occurs when you make that label call before an Object has been created on the heap.

    Car car = new Car(4,2,"blue"); // keyword 'new' puts car on the heap. Rather it puts an Object of type Car on heap and you labeled it car.

    Car eCar;

    eCar.setWheelNum( 4); // null pointer exception

  • 5 years ago

    Fyughj

  • ?
    Lv 4
    5 years ago

    Java.lang.nullpointerexception

  • Anonymous
    5 years ago

    For the best answers, search on this site https://shorturl.im/awsr5

    either the package u got is with error or the jar file that u hav needs to access some device and your phone is not allow to share it with app

  • 7 years ago

    I totally agree

Still have questions? Get your answers by asking now.