线程“main”中的异常 java.lang.Error:未解决的编译问题:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22728864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 17:30:51 来源:igfitidea点击:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
提问by user3475322
This is the error I'm getting
这是我得到的错误
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type
at hello.main(hello.java:11)
This is my code.
这是我的代码。
public class hello {
public static void main(String[] args) {
// TODO Auto-generated method stub
double area;
double radius;
Scanner input = new Scanner(System.in);
System.out.print("???? ?????: ");
radius = input.nextDouble();
area = 3.14 * radius * radius;
System.out.println(area);
}
}
采纳答案by SpringLearner
Have you imported Scanner class like import java.util.Scanner;
您是否导入了 Scanner 类 import java.util.Scanner;
回答by SpringLearner
You need:
你需要:
import java.util.Scanner;
at the top of your file. You've got to import it.
在文件的顶部。你必须导入它。