总结:主要是方法的调用不能错,比如浮点型,整型,字节型,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);
		}
	}
}

  

相关文章:

  • 2021-05-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案