您的位置:首页 > 编程语言 > Java开发

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包*
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: