首先要在代码的开头导入 import java.util.Scanner; public class test{ Scannner s=new Scanner(System.in); int i=s.nextInt(); }