這是一個Java/Groovy問題,即時通訊將執行此功能以在我的網站中的搜索機制中實現。我有兩個列表:對於語句問題Java/Groovy雙重
String [] lista = temp.split() // ignore the temp part
String [] searchLista = search.split() // ignore the search part
基本上,列表是這樣的:
lista = {a, b, c, d}
searchLista= {a, b, a, d}
boolean test
我想驗證如果在列表「LISTA」任何元素是「searchLista」一樣。對於我做了以下功能:
for(int i = 0; i< lista.length-1; i++){
for(int j = 0; j< searchLista.length-1; j++) {
if(lista[i].contains(searchLista[j])){
test = true
##
}
}
}
我的問題是,如果這種驗證是正確的:「LISTA [I]。載有(searchLista [J]。)」,布爾變量測試變得真實和明年我想跳出兩者。在## s的地方有一個簡單的'break'會做到嗎?
標籤是非常類似於'goto',而我們都知道,「goto語句是有害的」 – 2011-05-25 15:20:29
(同時也是「‘goto語句是有害的’有害」等):) @邁克爾:我認爲它幾乎不像goto一樣武斷......但我仍然更喜歡更簡單的方法。 – 2011-05-25 15:21:08
「去聲明考慮非常方便,當使用少量和適當」只是不是很吸引人我猜 – 2011-05-25 15:38:27