把类名Math改为其他类名如MathTest,再使用Math.PI来打印PI的值,否则类名和Math数学类的类名冲突而出错了,修改如下:
public class MathTest {
public static void main(String[] args) {
System.out.println("圆周率π的值为:"+Math.PI);
}
}
你这个类名是Math,然后你又用Mach.PI 他当你是调用类的字段了。把类名换个,然后导入相应Math包就行。