标签:tin int scanner lin pre else next 回车 new
Scanner scanner = new Scanner(System.in);
String oneStr = sc.next(); //字符串以空格结束,不包含字符串
String twoStr = sc.nextLine(); //字符串以回车结束
if (sc.hasNext()) { //一般会先判断再读取
Int in=sc.nextInt();
}else{
System.out.println("输入的不是整数!");
}
sc.close(); //最后要关闭
标签:tin int scanner lin pre else next 回车 new
原文地址:https://www.cnblogs.com/liehen2046/p/12166227.html