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

Thread: NullPointerException when using methods to find matching chars in two arrays.

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default NullPointerException when using methods to find matching chars in two arrays.

    I am currently
    Last edited by Javaisfrustrating; November 22nd, 2011 at 10:55 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: NullPointerException when using methods to find matching chars in two arrays.

    Exception in thread "main" java.lang.NullPointerException
    at DMVExam.getNumCorrect(DMVExam.java:52)
    This error message says you are trying to use a variable with a null value at line 52.
    Look at line 52 and see what variable is null and backtrack to see why it does not have a valid value.
    If you can not see what variable is null, add a println just before line 52 and print out the values of all the variables used in line 52.

  3. #3
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: NullPointerException when using methods to find matching chars in two arrays.

    public DMVExam() {
        char[] solution =
    You should follow Norm's advice as it explains how to track down your problems in the future without relying on others. However I have given you a hint.
    Improving the world one idiot at a time!

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: NullPointerException when using methods to find matching chars in two arrays.

    Why don't IDEs and compilers give warnings for shadowed variable definitions?
    So many students have that problem.

  5. #5
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: NullPointerException when using methods to find matching chars in two arrays.

    More closer hint:
    class A{
    private int variable;
    A(){
    int variable;
    }
    }

Similar Threads

  1. finding the amt of words and chars in a give file
    By mysticCHEEZE in forum What's Wrong With My Code?
    Replies: 5
    Last Post: November 3rd, 2011, 11:31 PM
  2. for loop with chars
    By dragon40226 in forum Loops & Control Statements
    Replies: 4
    Last Post: September 25th, 2011, 05:50 PM
  3. Passing Arrays Between Methods
    By kigroy in forum What's Wrong With My Code?
    Replies: 14
    Last Post: September 10th, 2011, 10:10 PM
  4. [SOLVED] Writing a program with arrays and class methods... PLEASE HELP?
    By syang in forum What's Wrong With My Code?
    Replies: 17
    Last Post: August 8th, 2011, 07:02 AM
  5. Replies: 2
    Last Post: April 21st, 2011, 06:32 AM