JAVA初学笔记---控制台输入:错误scanner
2017-08-28 12:02
302 查看
源代码
——————
public class scanner { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a number in radius: "); double radius = input.nextDouble(); double area = radius * radius * 3.14159; System.out.println("The area for the cicle of radius " + radius + "is " +area ); } }
此项程序遇到的错误
——————
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 从控制台读取.scanner.main(scanner.java:7)
解决方案
——————
*缺少import java.util.Scanner ;
在第一行记入即可
因为Scanner属于util包
所以需要导入util包*
相关文章推荐
- java初学笔记之java的几个标准输入
- java 控制台scanner的中文输入问题
- [Java] Scanner(System.in) 从控制台输入
- java从控制台输入数值之Scanner()
- (第3讲)Java如何获得用户在控制台输入的东西(Scanner和BufferedReader的区别)
- java初学 Scanner 中 输入数字和字符串的方法
- java学习笔记7对于将从控制台进行输入改为文件
- 控制台输入类java.util.Scanner
- java学习笔记(十):scanner输入
- Java笔记5:解决MyEclipse控制台输入中文乱码输出问题(Eclipse也可以用)
- 控制台输入数据类java.util.Scanner
- Java---逻辑运算符、Scanner控制台输入、三目运算符、生成随机数的两种方法
- Java笔记(7)-输入、输出流、File类、InputStream、Reader、文件字节流、文件字符流、缓冲流、随机流、数据流、对象流、序列化和对象克隆、Scanner解析文件、Console流
- Java笔记(1):从控制台读取输入
- Java学习笔记之[ 利用扫描仪Scanner进行数据输入 ]
- 控制台输入类java.util.Scanner
- Java中的Scanner—控制台输入
- Java控制台输入ScannerDemo
- JAVA中使用Scanner连续输入int和String错误的解决方案
- java 控制台输入(标准输入法)以及Scanner的用法、以及Console的用法