我是第一次学习Java.我写了一个简单的程序:
public class Solver {
public static void main(String[] args) {
double angle = 1.5;
double height = Math.sin(angle);
System.out.print("The sine of " + angle + " is: ");
System.out.println(height);
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试编译它时,我在终端中收到以下错误:
Solver.java:4: cannot access Math
bad class file: ./Math.java
file does not contain class Math
Please remove or make sure it appears in the correct subdirectory of the classpath.
double height = Math.sin(angle);
^
1 error
Run Code Online (Sandbox Code Playgroud)
为什么我不能访问Math类?
在Java中,当一个声明一个字符串变量时,单词"String"被大写,但它不在我遇到的任何其他类型中(例如"int"或"double").为什么是这样?这只是设计师的一些奇怪的武断决定吗?