The nextline () method is undefined for Scanner type

advertisements

I am trying to understand what it means and why it is wrong.

import java.util.Scanner; 

public class Relevent {
    public static void main(String[]args){
        Scanner x = new Scanner(System.in);
        System.out.println( x.nextline());
    }
}

The Eclipse IDE tells me this is wrong and gives this message:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
    The method nextline() is undefined for the type Scanner
    at Relevent.main(Relevent.java:9)


What about writing x.nextLine()? Java is a case-sensitive language. You must follow API exactly as written there.

The method name nextline looks not understandable/obvious, doesn't it? So, the best practice in Java programming is writing all names in camel case style (except for final and static variables, e.g. MY_FINAL_VARIABLE).