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!

line 105 in the code is line 4 in this.

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

Sorted now, thank you!

Excellent! Please mark this "solved" for our knowledge base.
Cheers
J

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.