Array Parameter mit 2 Klassen - NullPointerException

Hallo,

Kann mir jemand helfen und sagen, was ich hier wohl übersehen habe. 2 Klassen, runner class nimmt den user input als array. Runner class ruft Methode aus der class ab. Danke sehr!!!!
Code:
import java.util.Scanner;

public class RunnerList {

    public static void main(String args[]) {
        int number[] = new int[10];

        Scanner scan = new Scanner(System.in);
        System.out.println("Enter a list of 10 numbers.");

        for (int i = 0; i < 10; i++) {
            number[i] = scan.nextInt();
        }

        for (int i = 0; i < 10; i++)
            System.out.print(number[i]);

        List l = new List();
        l.createLists(number);
        System.out.println(l);

    }

}
Code:
public class List {
    private int[] evenList;
    private int[] oddList;
    private int[] negativeList;
    private int evenCount = 0, oddCount = 0, negativeCount = 0;

    public void createLists(int[] userInput) {

        for (int i = 0; i < userInput.length; i++) {
            if (userInput[i] < 0) {
                negativeList[negativeCount] = userInput[i];
                negativeCount++;
            }

            else if (userInput[i] % 2 == 0) {
                evenList[evenCount] = userInput[i];
                evenCount++;
            }

            else {
                oddList[oddCount] = userInput[i];
                oddCount++;
            }
        }

    }

    public String toString() {

        int i;
        String even = "";
        String odd = "";
        String negative = "";

        for (i = 0; i < evenCount; i++)
            even += evenList[i] + "";
        for (i = 0; i < oddCount; i++)
            odd += oddList[i] + " ";
        for (i = 0; i < negativeCount; i++)
            negative += negativeList[i] + " ";

        String result = "Even List: " + even + "\nOdd List: " + odd + "\nNegative List: " + negative;

        return result;

    }

}
 
Passende Stellenanzeigen aus deiner Region:

Neue Themen

Oben