总结:主要是方法的调用不能错,比如浮点型,整型,字节型,so.on
int ====hasNextInt()
float--------hasNextfloat()
short ====hasNextShort()
package com.a.b; import java.util.Scanner; public class Ruo { public static void main(String[] args) { int a = 0; // 创建Scanner对象c,其内容来自InputStream类 Scanner c = new Scanner(System.in); System.out.println("请输入一个整数"); while (c.hasNextInt()) { // a=Integer.parseInt(a);这是什么又在乱写了啊 a = c.nextInt(); System.out.println(a); } } }