javaeclipseeclipse-oxygen

String.split() method doesn't work in eclipse oxygen version 4.7.0M2


String.split() method doesn't work in Eclipse Oxygen version 4.7.0M2 I have prepared a simple code snippet

public static void main(String[] args) {
    // TODO Auto-generated method stub
    int T = Integer.parseInt(System.console().readLine());
    while(T > 0)
    {
        int N = Integer.parseInt(System.console().readLine());
        String inp = System.console().readLine();
        String[] inp =   inp.split("\\s+");
        T--;
    }
}

Please find the Screenshot of the error

split() showing error in IDE. I am using JRE 1.8. The same function work correctly with the same JRE in Eclipse Luna. Please anyone help me to understand the exact problem.


Solution

  • You defined two variables with the same name: String inp and String[] inp. Give the string array a different name.