-2
我把系統打印出來看看問題出在哪裏,2和7是在無限循環中不斷重複的兩個。這部分代碼假設搜索列表並找到用戶放入的匹配項,但每次使用搜索時,GUI都會凍結或陷入無限循環。誰能幫我解決這個問題嗎?如何解決這個無限循環?
這裏是我的代碼有:
if (whichOne.equals("Search"))
{
System.out.println("1");
String[] results = new String [5];
int count = 1;
list.moveCursorToRear();
int last = list.cursor;
list.resetCursor();
while(list.hasNext() || list.cursor == last)
{
int found = list.search(searchField.getText());
String result = list.spaces[found].getData();
System.out.println("2");
if(current != found)
{
list.stepCursorBack();
System.out.println("3");
if(list.cursor == list.head)
{
results[count] = result;
System.out.println(results[count]);
list.spaces[current].setLink(list.spaces[found].getLink());
count++;
System.out.println("4");
}
else
{
results[count] = result;
System.out.println(results[count]);
list.spaces[current].setLink(list.spaces[list.cursor].getLink());
count++;
System.out.println("5");
}
list.getNext();
System.out.println("6");
}
else
{
//break;
//System.exit(0);
list.hasNext();
System.out.println("7");
}
}
'list'是什麼樣的對象? – unholysampler 2012-02-29 00:55:46