I'm getting a null pointer exception on lines 17, and 22. I'm not positive, but does it have to do with "int number1 = data[0];" having to be static?

int number = 100;

public static final int[][] NUMBERS = {
	{ 1205, 1206 }
};

public static boolean method1() {

        int used1, used2;

	for (int[] data : NUMBERS) {
		int number1 = data[0];
		int number2 = data[1];
        }

	if (used1 == number && used2 == number1) {		
		method2(number, number1, number2);
        }				
}

public static boolean method2() {
	int count = getCount(number1);
			
	if (count <= 5) {
                //DO STUFF HERE
	        return true;
	}
        else if (count > 5) {
                //DO STUFF HERE
		return true;
	}
	return false;
}

Please post the full text of the message.

All you need to know is "null pointer exception on lines 17, and 22"

There is no such a NPE (NullPointerException) on primitive type variable. In this case, you are talking about number, number1, and number2 variables. Anyway, line 17 is calling a different method which is not line 22. Look closely how you declare the method.

All you need to know is "null pointer exception on lines 17, and 22"

That's a response that won't help you. You may think you know what we need to know, but if your knowledge was complete and correct then you would also know the answer to your problem.

Making something static won't cause an NPE.
The lines you refer to contain no object references, and are therefore most unlikely to cause an NPE.
The lines you refer to DO contain undefined variables (as I explained in a post to your earlier thread on exactly the same subject), but these will produce a "cannot be resolved to a variable" compiler error message and prevent you executing the code, thus making it impossible for you to generate any NPEs.

If you would like any more help, please post the exact complete error message and the exact complete code that caused it. We can then decided what we need to know to answer your problem.

The error is probably occurring in the getCount method which is not shown in the code.
The stack trace goes from 17 to 22 to ????

Member Avatar for hfx642

First...
You are declaring method2 as a method which will return a boolean.
However, your call to method2 does NOT expect a result.

Second...
Your call to method2 is passing 3 parameters.
However, your method2 does not handle ANY parameters.

First... Second...

Yeah. This code won't even begin to compile, so the (incomplete) claims of an NPE look very shaky. IMHO we're wasting our time with this one, unless he wants to give us accurate and complete info.

s/he is my winner

your small mistake is directly in line: 2

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.