我认为我格式错误或存在逻辑错误,老实说我不知道。我在程序底部评论了错误。非常感谢所有帮助。
public static void main (String args[]) {
String userInput;
Scanner kb = new Scanner (System.in);
System.out.print("Enter a string of characters: ");
userInput = kb.nextLine();
int length = userInput.length();
for (count=0; length<count; count++) {
char letter=userInput.charAt(count);
System.out.print(letter + " ");
}
}
错误:
javac "StringDown.java" (in directory: /home/user/Downloads)
StringDown.java:16: cannot find symbol
symbol : variable count
location: class StringDown
for (count=0; length<count; count++)
^
StringDown.java:16: cannot find symbol
symbol : variable count
location: class StringDown
for (count=0; length<count; count++)
^
StringDown.java:16: cannot find symbol
symbol : variable count
location: class StringDown
for (count=0; length<count; count++)
^
StringDown.java:18: cannot find symbol
symbol : variable count
location: class StringDown
System.out.print(userInput.charAt(count));
^
4 errors
Compilation failed.