Java - Input & Output & FileIO

需要调用Scanner类 

Scanner in = new Scanner(System.in);    //Scanner类

in.nextLine();  // return String regardless of space

in.next();  // return String , split with space

in.nextInt(); //return int

in.nextDouble();  //return double

in.hasNext();  //return boolean

in.hasNextInt();  //return boolean

in.hasNextDouble();  //return boolean


不可见输入

Console cons = System.console();

String username = cons.readLine("User name: ");

char[] password = cons.readPassword("Password: ");

Java - Input & Output & FileIO_第1张图片

Java - Input & Output & FileIO_第2张图片

Java - Input & Output & FileIO_第3张图片

Java - Input & Output & FileIO_第4张图片

你可能感兴趣的:(Java学习笔记)