所以,我正在为我的 Java 类编写这段代码,我遇到了这个困扰我的问题,对不起,如果它有点长,我是 Java 编码的新手。
import javax.swing.*;
public class DebugEight4
{
public static void main(String[] args)
{
int x = 0, y;
String array[] = new String[100];
String entry;
final String STOP = "XXX";
StringBuffer message = new
StringBuffer("The words in reverse order are\n");
entry = JOptionPane.showInputDialog(null,
"Enter any word\n" +
"Enter " + STOP " when you want to stop");
while(!(entry.equals(STOP)))
{
array[STOP] = entry;
entry = JOptionPane.showinputDialog(null,
"Enter another word\n" +
"Enter " + STOP + " when you want to stop");
}
for(y = 0; y > 0; ++y)
{
message.append(array[y]);
message.append("\n");
}
JOptionPane.showMessageDialog(null, message);
}
}
我得到一个 DebugEight4.java:17: error: ')' expected "Enter " + STOP " when you want to stop"); (箭头指向 STOP 和 " 之间的空格)^
DebugEight4.java:17: 错误:非法启动表达式“当你想停止”时输入“+ STOP”);(箭头指向')')^
DebugEight4.java:23: error: ')' expected ("Enter " + STOP + " when you want to stop"); (箭头指向;)^
这都是一个问题,我遇到的另一个问题是:
DebugEight4.java:20:错误:不兼容的类型数组 [STOP] = 条目;必需:int found:String(aarow 指向 STOP
DebugEight4.java:21:错误:找不到符号条目 = JOptionPane.showinputDialog(null,符号:方法
很抱歉这篇长篇文章,但正如我所说,我是新手,希望得到一些帮助,谢谢大家!