-4
你好我正在用Java做一个命令系统。举个例子:你输入“date”,你会看到时间和日期,但是这个问题出现了,当我试图修复它时,它是一个永无止境的循环。这里是我的代码说明一下:Java Socket永无止境
switch(string){
case "date":
//Give date
case "random":
//The thing is when you type "random" it will wait on the next input from the user and store it in this variable.
while(!string2.equals("BREAK")){
String string2 = (String) inputdata.readObject();
//It will process the users next information if the user NOT type "BREAK".
}
break;
//The problem is that the variable "string2" must be outside the while loop BUT it NEEDS in the loop. I tried with do while loop but the same problem happend.
}
如果我必须解决这个问题,我必须做的循环回路中循环的回路循环中.... 感谢您的回答。 :D如果你不明白,我不明白我的问题在开始。
没有你在compairing试图equalsIgnoreCase ......有时候你为什么用'的readObject()'来读取用户输入的信息occours由于区分大小写 – kirti 2014-09-30 15:38:10
? – 2014-09-30 15:40:44
为什么不readObject(),我应该使用什么? – Tor 2014-09-30 15:44:12