Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: nullPointerException

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question nullPointerException

    hi, i'm getting constructor null pointer exception but i don't know what has gone wrong...

    private int capacity; // maximum capacity of the board
    	private double minimum; // minimum distance of the flyer
    	private SortedLinkedList sortedList;
    	private int size = 0;
     
    	public ScoreBoard() {
    		capacity = 10;
    		minimum = 0.0;
    		sortedList = new SortedLinkedList();
    	}
     
    	public ScoreBoard(int capacity) {
    		this.capacity = capacity;
    		minimum = 0.0;
    		sortedList = new SortedLinkedList(capacity);
    	}
     
    	public ScoreBoard(double minimum) {
    		this.minimum = minimum;
    		capacity = 10;
    		sortedList = new SortedLinkedList();
    	}
     
    	public ScoreBoard(int capacity, double minimum) {
    		this.capacity = capacity;
    		this.minimum = minimum;
    		sortedList = new SortedLinkedList(capacity);
    	}


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: nullPointerException

    Post the full text of the error message and stack trace which will include code line numbers, then indicate which line in the code you posted is the last line number mentioned in the error message, the location of the NPE.

    OR, post runnable code that demonstrates the problem.

    OR, to debug the code yourself, you could:

    - add prints to your code to determine which of the objects in the line indicated by the error message is null and work backwards to determine why that object was not initialized properly.

    - use a debugger to accomplish the same as the previous suggestion.

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: nullPointerException

    it's an assignment and the feedback was just nullPointerException for constructor. it's alright... i think i should give up amending it. i need to study for tomorrow's test thx anyway!

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: nullPointerException

    Well, the feedback isn't very helpful, and I don't see an NPE in what you've posted. I assume those are 4 constructors for the class ScoreBoard.

    Good luck on your test!

Similar Threads

  1. [SOLVED] NullPointerException
    By hooshdar3 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 11th, 2014, 07:29 AM
  2. why am I getting NullPointerException.
    By mia_tech in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 24th, 2012, 11:33 AM
  3. NullPointerException
    By Alket in forum Member Introductions
    Replies: 1
    Last Post: June 7th, 2012, 07:09 AM
  4. NullPointerException
    By deathmatex in forum Exceptions
    Replies: 4
    Last Post: March 27th, 2012, 03:54 AM
  5. [SOLVED] Nullpointerexception
    By kbwalker87 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 14th, 2010, 10:33 PM