错误:类卷中未找到主方法,请将主方法定义为: 公共(public)静态无效主(字符串[]参数) 或者 JavaFX 应用程序类必须扩展 javafx.application.Application
import java.util.*;
class volume {
private int x;
public float volume(float l) {
return (l * l * l);
}
public float volume(float r, float h) {
return (3.14f * r * r * h);
}
public float volume(float l, float b, float h) {
return (l * b * h);
}
}
class main {
public static void main(String[] args) {
volume a = new volume();
System.out.println("volume of cube=" + a.volume(10));
System.out.println("volume of cylinder=" + a.volume(10, 10));
System.out.println("volume of cuboid=" + a.volume(10, 10, 10));
}
}
最佳答案
将您的 main
方法移至 volume
类,并将 volume
类公开。您不需要class main
。
关于java命令提示符编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27522700/