0

我正在尝试用java制作一个油漆分配器模拟原型控制台应用程序。到处搜索,似乎无法找出为什么这段代码不起作用。我使用网豆。我试图用这段代码做的是显示菜单,要求用户输入,当用户输入一个数字时,它会从菜单中选择该选项,然后我需要在菜单工作后开始让这些选项工作。感谢任何帮助。到目前为止,我的代码如下所示。

    package paintdispensersimulation;

    import java.util.Scanner;
    /**
    *
    * @author Kris Newton (M2124910)
    */
    public class PaintDispenserSimulation   //
    {                                       //Open Public Class 
    public static void main(String[] args)  //
    {                                       //Start Main
        Scanner in = new Scanner (System.in);   //
        int option;                             //
        boolean quit = false;                   //Declare variables                                  
        do  //
        {   //Start Do
            System.out.println("Please Make a selection:");                     //
            System.out.println("[1] Process New Job(Decimal Values)");          //
            System.out.println("[2] Process New Job(RGB Hexadecimal Values)");  //
            System.out.println("[3] Calibrate Dispenser");                      //
            System.out.println("[4] Display Summary Of Jobs");                  //
            System.out.println("[0] Exit");                                     //Print Menu
            option = in.nextInt();  //Declare User Input
            switch (option)         //Declare Switch
            {                       //Start Switch            
                case 1:                                                                     //If Option = 1
                    System.out.println("You Chose To: Process New Job(Decimal Values)");    //Print            
                    break;                                                                  //Break
                case 2:                                                                             //If Option = 2
                    System.out.println("You Chose To: Process New Job(RGB Hexadecimal Values)");    //Print  
                    break;                                                                          //Break                                                                          
                case 3:                                                                     //If Option = 3
                    System.out.println("You Chose To: Calibrate Dispenser");                //Print 
                    break;                                                                  //Break
                case 4:                                                                             //If Option = 4
                    System.out.println("You Chose To: Display Summary Of Jobs");                    //Print
                    break;                                                                          //Break
                case 0:                                                                     //If Option = 0
                    quit = true;                                                            //Quit                                                            
                    break;                                                                  //Break
                default:                                                                            //If Option Invalid
                    System.out.println("Selection Invalid: Please enter a valid selection.");       //Print           
            }   //End Switch           
        }   //End Do 
        while (!quit);                              //While Quit = True
        System.out.println("You Chose To: Exit");   //Print
    }   //End Main    
}   //End Public Class

这是我尝试运行时收到的消息。

run:
java.lang.VerifyError: Constructor must call super() or this() before return in method paintdispensersimulation.PaintDispenserSimulation.<init>()V at offset 0
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
    at java.lang.Class.getMethod0(Class.java:2685)
    at java.lang.Class.getMethod(Class.java:1620)
    at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 1 second)
4

1 回答 1

0

我能够在 Eclipse 中运行此代码。

VerifyError 可能意味着字节码无效。

基本上,这是一个编译器错误,或者如果类文件已损坏

尝试在不同的机器上使用不同的 JDK 版本进行编译。

于 2013-02-01T20:06:21.417 回答