I am writing a program that will take several numbers and display them in ascending order and then descending order. When I try to assign the input to the array, I get a null pointer exception and I am not sure why. Any help would be appreciated.
Here is my code:
static int[] numbers;
public static void main(String[] args) {
int i=0;
while(i<50)
{
String input = JOptionPane.showInputDialog("Enter any number or type X to exit");
System.out.println(input);
if(input.equals("X"))
{
break;
}
numbers[i]=Integer.parseInt(input);//This is where i get the exception
i++;
}