I have this line of code

if (passLength >= 1) {
            for (i = 0; i <= 62; i++) {
                if (ascii[i] == inPass[0]) {
                    outPass[0] = inPass[0];
                    i=100;
                }

            }
        } else {
            return "Please enter a Password";
        }

I basically want the program to check through an array of ascii characters until it finds one which matches the input and there are a few of these statements, one after the other. The outPass and inPass are char arrays and I need to transfer the value from inPass[0] to outPass[0] when a match is found. It seems to just throws

java.lang.NullPointerException
    at Checker.Check(Checker.java:105)
java.lang.NullPointerException
    at Checker.Check(Checker.java:105)

whenever the method is called and I can't see what i've done wrong. Thanks!

Are you sure your arrays are initialised? Just declaring them isn't enough...

char[] outPass;  // declares a reference variable of type char[]. Its initial value is null;
// any attempt to use outPass will give a null pointer exception
outPass = new char[99]; // creates a char array, and sets var to refer to it.
// can now use outChar

Edited 3 Years Ago by JamesCherrill

This question has already been answered. Start a new discussion instead.