使用前引入:
impor java.util.Scanner;
使用前申明:
Scanner scan = new Scanner(System.in);
使用:
int height = scan.nextInt();
double wealth = scan.nextDouble();
string isHandsome = scan.next();
boolean isHandsome = scan.nextBoolean();
ps:
用户输入字符串当作boolean使用时:
System.out.println("handsome? Yes/No");
string ishandsome = scan.next();
if( ishandsome.equals("Yes")){
}
网友评论