gpt4 book ai didi

java - 编译代码时出现非法的起始表达式错误

转载 作者:行者123 更新时间:2023-12-02 11:07:11 25 4
gpt4 key购买 nike

好的,我可以重做一些代码,但是当我尝试编译时,我总是遇到错误。错误:表达式的开始非法(第17行)...箭头指向joption代码的末尾。我不明白它要我做什么。这是代码:

public class Project0 {

public static void main(String[] args) {

char uppercase = 'E';
char lowercase = 'e';
int isLower=0;
int isUpper =0;
String inputWord;

inputWord = JOptionPane.showInputDialog(null, "Please enter a sentence");
while (!inputWord.equals("stop"))
{
isLower = wordIsThere(inputWord, lowercase);
isUpper = wordIsThere(inputWord, uppercase);

JOptionPane.showMessageDialog(null, ("Number of " +inputWord+ " Lower: " +isLower+ "Upper: " +isUpper+));

inputWord = JOptionPane.showInputDialog(null, "Please enter a sentence or enter stop");
isUpper=0;//reset
isLower=0;
}//while ends here.

System.out.println("ENDS");
}//main
public static int wordIsThere(String findMe, char theLetter)
{
int count=0;
for (int i=0; i<findMe.length(); i++ )
if (findMe.charAt(i) == theLetter)
count++;
return count;
}
}

最佳答案

+方法中删除最后一个showMessageDialog运算符

JOptionPane.showMessageDialog
(null, ("Number of " +inputWord+ " Lower: " +isLower+ "Upper: " +isUpper));
^

关于java - 编译代码时出现非法的起始表达式错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19011076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com