Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2014
    Posts
    6
    Rep Power
    0

    Default Very annoying NPE.

    So I'm making a program that tests you on your square numbers. It worked, but I wanted to split it up into smaller files since I had everything in two files. It's Java 8 syntax if it makes a difference.
    My code: https://github.com/Injustice/SquareN...ustice/squares

    Error: Exception in thread "main" java.lang.NullPointerException at org.injustice.squares.ui.QuestionPanel.setQuestion (QuestionPanel.java:79)
    at org.injustice.squares.ui.MainFrame.<init>(MainFram e.java:20)
    at org.injustice.squares.mechanics.DataHandler.<init> (DataHandler.java:38)
    at org.injustice.squares.Square.<init>(Square.java:12 )
    at org.injustice.squares.Square.main(Square.java:15)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:491)
    at com.intellij.rt.execution.application.AppMain.main (AppMain.java:120)

    Any help would be greatly appreciated. Ask if you need any help clarifying the code.

  2. #2
    Join Date
    Mar 2014
    Posts
    6
    Rep Power
    0

    Default Re: Very annoying NPE.

    EDIT: I have found that calling setQuestion() is what gets the NPE.

  3. #3
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: Very annoying NPE.

    Let me guess. It was at line 79 :)

    java.lang.NullPointerException at org.injustice.squares.ui.QuestionPanel.setQuestion (QuestionPanel.java:79)
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,453
    Rep Power
    25

    Default Re: Very annoying NPE.

    What variable has the null value?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Join Date
    Mar 2014
    Posts
    6
    Rep Power
    0

    Default Re: Very annoying NPE.

    getHandler() returns null.

  6. #6
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,453
    Rep Power
    25

    Default Re: Very annoying NPE.

    The code should test the value that is returned BEFORE using it someplace where it can cause an exception.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Annoying syntax error in Eclipse!!
    By mistajokka in forum New To Java
    Replies: 3
    Last Post: 02-02-2012, 07:53 PM
  2. Creating a movable .jar...super annoying :/
    By Tombomb in forum New To Java
    Replies: 11
    Last Post: 02-02-2012, 04:13 PM
  3. Annoying Popups
    By camickr in forum Suggestions & Feedback
    Replies: 24
    Last Post: 03-01-2011, 03:58 PM
  4. Annoying database problem!
    By DC1 in forum New To Java
    Replies: 2
    Last Post: 05-29-2008, 09:43 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
  •