我很新的Java和编程一般。我在下面的代码工作使用NetBeans IDE:错误:无法找到或加载主类shoutbox.ShoutBox
package ShoutBox;
import java.util.Scanner;
public class ShoutBox {
public static void main(String args[]){
ShoutBox shoutbox = new ShoutBox();
}
Scanner input = new Scanner(System.in);
int selection = 0;
public void message() {
String message[] = new String[10]; // declare array
message[0] = "01: Free Will Exists.";
message[1] = "02: Since Free Will Exists, Evil Exists.";
message[2] = "03: Evil, being evil, will not stop on its own.";
message[3] = "04: For Good to continue to exist, Evil must be stopped.";
message[4] = "05: It is good that Good exists.";
message[5] = "06: It is good to stop evil.";
message[6] = "07: Good persons will attempt to stop evil or else they are not good.";
message[7] = "08: Evil brings war.";
message[8] = "09: Since evil brings war and will not stop, good must fight and win those wars.";
message[9] = "10: Just war exists.";
System.out.println();
String cm = new ShoutBox().shoutOutCannedMessage(message); //call to shoutOutCannedMessage
String rm = new ShoutBox().shoutOutRandomMessage(message);
System.out.println("Philosophy: ");
System.out.println(cm);
System.out.println("Your Random Message: ");
System.out.println(rm);
}
public String shoutOutCannedMessage(String[] message)
{
ShoutBox shoutbox = new ShoutBox();
for (String element : message)
{
System.out.println(element); //print out messages
}
System.out.print("Select a message: ");
System.out.println();
selection = input.nextInt();
String cannedMessage = message[selection];
return cannedMessage;
}
}
它建立和负载只是罚款,但不会运行,并给我的错误代码:“错误:无法找到或加载主类在线留言板.ShoutBox“。有人知道为什么吗?
你不小心把一个右括号'}'吼吼箱箱后'=新的在线留言板();'? – theKidOfArcrania
我会尝试删除一个。 – Whiteknightsky
这只是创造了更多的错误。如果不在那里,我不确定闭幕的位置。 – Whiteknightsky