I'am getting a
java.lang.NullPointerException
when trying to use regex in the following code:
public static void scanSTAFFELNR() {
    String STAFFELNR = CsvScanner.values.get(1);  // My values are stored in a ArrayList ( values). Here i want to get the second one.
    if (STAFFELNR.matches("[0-9]+")) { // Here i want to check, if the String is a number. 
        System.out.println("erfolg");
    } else {
        STAFFELNRMessage = "Fehler bei STAFFELNR, STAFFELNR muss zwischen 0-3 sein";
        Gui.fehlerCounter++;
    }
}
When i remove the STAFFELNR.matches
and replace it with a STAFFELNR == "Hello"
, i get no error.
I dont know how to fix this error on my code.