java命令提示符编译错误

标签 java compiler-errors

错误:类卷中未找到主方法,请将主方法定义为: 公共(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/

相关文章:

当我释放的数量超过获取的数量时,Java 信号量会增加许可数量

java - Liferay 6.1 的私有(private)成员(member)网站

java - 如何使用 Java 获取已安装的 RPM 包列表

c - 反转数组时,出现以下错误: invalid operands to binary * (have ‘int’ and ‘int *’ ) [closed]

haskell - Haskell Cabal : C compiler cannot create executables

compiler-errors - 为什么我在编译时得到 "Cannot unify ' t ₂' with type ' f3 2'",我该如何解决?

java - 是否可以在java Web应用程序中获取客户端操作系统用户名?

c++ - 在只读对象中分配成员时出错

linux - freebsd 下的 makefile 无法编译(适用于 linux)

用于测试类的 Java Bean