Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By doWhile

Thread: NullPointerException

  1. #1
    JG4m3r is offline Member
    Join Date
    Mar 2012
    Posts
    16
    Rep Power
    0

    Default NullPointerException

    Hi guys, so I'm getting this error in my program. I'm getting a NullPointerException on this code:

    Java Code:
    p = new Player(team, i);
    players.add(p);
    I've got a class with the name Player, and I even tried calling two of the methods inside of it just to test, and they gave me the desired result. So I don't get it guys, why am I getting an error when I'm trying to add the Player variables p to the ArrayList players?

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default Re: NullPointerException

    Move to New To Java

    We have no clue based upon what you posted. What is null on the line that throws the Exception? Add some println's to find out.
    quad64bit likes this.

  3. #3
    chipp's Avatar
    chipp is offline Member
    Join Date
    Jul 2011
    Posts
    62
    Rep Power
    0

Similar Threads

  1. NullPointerException
    By jayragz in forum NetBeans
    Replies: 5
    Last Post: 05-12-2011, 05:19 PM
  2. NullPointerException
    By maxspyderweb in forum New To Java
    Replies: 5
    Last Post: 03-02-2011, 10:42 AM
  3. Nullpointerexception?
    By Pulgo in forum New To Java
    Replies: 5
    Last Post: 01-05-2011, 04:05 PM
  4. NullPointerException
    By JohnST in forum New To Java
    Replies: 13
    Last Post: 01-06-2010, 12:37 AM
  5. NullPointerException
    By tommyyyy in forum New To Java
    Replies: 9
    Last Post: 03-26-2009, 10:51 PM

Posting Permissions

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