Scanner(System.in)中读取字符串容易犯的错误!
Scanner(System.in)中先用nextInt,再用nextLine时,容易犯的错误!使用Scanner(System.in)连续读取整数和字符串时,应连续使用两次nextLine()。像nextInt、nextShort、nextLong、nextFloat、nextDouble等基本数据类型输入时,会遗留下一个“回车键”,这个“回车键”会被下面的nextLine所获取(消除)。...
原创
2019-07-08 12:45:58 ·
1404 阅读 ·
0 评论