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 2 of 2

Thread: ArrayList problem, help me to find out the error!

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ArrayList problem, help me to find out the error!

    Hi, here is part of my code, after compilation, I get a Null Pointer Exception on the ORANGE part, I don't know where goes wrong.

    for (int i = 0; i < N_BITS; i++){
    ResultButton button = new ResultButton(0);
    add(button, constraint);
    resArr.add(button);
    }

    Note:
    1. N_BITS is a just a constant.
    2. resArr is an ArrayList, containing ResultButton, instance variable.
    3. class ResultButton is defined by myself.

    HELP ME TO FIGURE OUT THE PROBLEM, THANK YOU!


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts

    Default Re: ArrayList problem, help me to find out the error!

    I would guess somewhere in your code you wrote a line like:
    private ArrayList<ResultButton> resArr;
    ...but did you ever use new on that resArr?

Similar Threads

  1. Hey! can anyone help me . i cant find an error (beginner)
    By fredsilvester93 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 19th, 2012, 08:25 AM
  2. 'Can't find file' error
    By WayneC in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: May 14th, 2012, 01:30 AM
  3. Please Help me Find the Error
    By jugalrockz in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 18th, 2012, 01:31 AM
  4. can any one plz find the error.
    By shalini_sns in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 23rd, 2011, 05:26 PM
  5. Need help, cannot find error
    By Imeri0n in forum What's Wrong With My Code?
    Replies: 13
    Last Post: December 5th, 2010, 04:26 PM

Tags for this Thread