运行出现这个Main.java:2: error: class main1 is public, should be declared in a file named main1.java public class main1 { ^ Main.java:70: error: cannot find symbol Scanner sc = new Scanner(System.in); //通过键盘输入工具 ^ symbol: class Scanner location: class main1 Main.java:70: error: cannot find symbol Scanner sc = new Scanner(System.in); //通过键盘输入工具 ^ symbol: class Scanner location: class main1 Main.java:102: error: cannot find symbol Scanner sc = new Scanner(System.in); //通过键盘输入工具 ^ symbol: class Scanner location: class main1 Main.java:102: error: cannot find symbol Scanner sc = new Scanner(System.in); //通过键盘输入工具 ^ symbol: class Scanner location: class main1 5 errors Error: Could not find or load main class Main
时间: 2024-04-25 21:25:54 浏览: 139
ADC.zip_STM32F103_brief2t1_declared3ck
这个错误是因为你的代码中有几个Scanner类没有被正确导入。你需要在代码的开头加上`import java.util.Scanner;`来导入Scanner类。此外,你的public类main1需要被声明在一个名为main1.java的文件中。如果你的文件名不是main1.java,你需要将public类名与文件名保持一致。最后,确保你的代码中没有其他错误,如拼写错误或语法错误。
阅读全文