java的新手,必须用java制作一个油漆分配器模拟原型控制台应用程序。在任何地方搜索,似乎无法找出为什么这个代码不会工作。我使用netbeans。我正在尝试用这个代码来显示菜单,询问用户输入,当用户输入一个数字时,它从菜单中选择该选项,然后我需要在菜单工作后开始让这些选项工作。任何帮助表示赞赏谢谢。到目前为止我的代码如下所示。
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)
答案 0 :(得分:0)
我可以在eclipse中运行此代码。
VerifyError可能意味着字节码无效。
基本上,这是一个编译器错误,或者如果类文件已损坏
尝试使用不同的JDK版本和不同的计算机进行编译。