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 - 什么是NullPointerException,我该如何解决?

java - 文件.createNewFile() : How to handle "unreported exception" error?

ios - 错误 : could not build Objective-C module 'Foundation'

java - 如何从netbeans创建可执行程序

java - JSON 数组中的参数

java - 解决静态方法歧义

animation - SceneKit Swift3 编译器错误

ios - Swift-音频-按键声音不断出错

c - 处理数以千计的类似错误