日期:2014-05-20  浏览次数:20651 次

大哥 大姐 帮帮小弟
class Text1
{
public static void main(String[] args)
{
int n=10;
int x=(int)(Math.random()*n);
System.out.println(x);
}
}


小弟刚刚上手java 遇见个问题 java不是自动加载lang包么 
为什么下面的代码不能编译呢 ?
报错:
Text1.java:6: 找不到符号
符号: 方法 random()
位置: 类 Math
  int x=(int)(Math.random()*n);
  ^
.\Math.java:6: 找不到符号
符号: 变量 PI
位置: 类 Math
  System.out.println(PI);
  ^
2 错误


不明白 不明白 换成java.lang.Math.random就可以编译 .
各位大哥大姐 帮我看看;

谢谢拉 





------解决方案--------------------
不知道你是怎么编译的,
你可以用IDE工具呀,
要能你是用命令时那出了问题吧?