|
在终端输入java -version
得到下面结果:
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)
本来以为大功告成,不料运行程序却吓出一身冷汗。程序如下:
//这是core java2 7th的一个例子
import java.util.*;
public class InputTest
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
// get first input
System.out.print("What is your name? ");
String name = in.nextLine();
// get second input
System.out.print("How old are you? ");
int age = in.nextInt();
// display output on console
System.out.println("Hello, " + name + ". Next year, you'll be " + (age + 1));
}
}
运行结果:
[samble@localhost programming]$ javac InputTest.java
----------
1. WARNING in InputTest.java
(at line 1)
import java.util.*;
^^^^^^^^^
The import java.util is never used
----------
----------
2. ERROR in InputTest.java
(at line 6)
Scanner in = new Scanner(System.in);
^^^^^^^
Scanner cannot be resolved to a type
----------
3. ERROR in InputTest.java
(at line 6)
Scanner in = new Scanner(System.in);
^^^^^^^
Scanner cannot be resolved to a type
----------
3 problems (2 errors, 1 warning)[samble@localhost programming]$
(附:以前我用GCC中的javac丛命令得到的错误也是一样,不过那个版本是1.4的)
查看JDK1.5的文档:
java.util
Class Scanner
java.lang.Object
extended by java.util.Scanner
确实有这个类, ,天啊,我见鬼了吗????
请大家稍微LOOK一LOOK这个帖子,谢谢!! |
|