您好我想实现一个while循环,用户可以输入一些字符串并通过输入一个空字符串来完成它。当我进入例如" Hello"," World",""循环确实无限延续,但它应该在空字符串后停止 - 我不知道为什么。你能帮我吗?
也许检查字符串是否不相等,空字符串是否有效?
这是我的代码:
public static void main(String[] args) {
write("Enter some words and end your input by an empty string.");
String input = readString("Input a word:");
while(input != "") {
input = readString("word:");
}
谢谢。