I want to read the input from my scanner into an arraylist. I already tried it but I always got a NullPointerException. Can somebody tell me why?
private static ArrayList<String> allWords;
private static int numberOfWords;
public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext())
        {
            String s = sc.next();
            allWords.add(s);
            numberOfWords++;
        }
        sc.close();
}
 
     
    