小编Rai*_*ley的帖子

为什么我的程序不能访问Java中的数学方法?

我是第一次学习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 math class

9
推荐指数
2
解决办法
2746
查看次数

为什么Java中的字符串变量声明大写?

在Java中,当一个声明一个字符串变量时,单词"String"被大写,但它不在我遇到的任何其他类型中(例如"int"或"double").为什么是这样?这只是设计师的一些奇怪的武断决定吗?

java string variables types declaration

7
推荐指数
1
解决办法
3527
查看次数

标签 统计

java ×2

class ×1

declaration ×1

math ×1

string ×1

types ×1

variables ×1