請幫我添加一些代碼來完成一個邏輯。我有一個搜索方法(公共字符串搜索(字符串url,字符串someword)),它通過jsp標題在內容中查找單詞。因此,這裏代碼完成一些搜索邏輯
String[] argi = {"http://www.google.com", "http://www.youtube.com"};
for (int i = 0; i < argi.length; i++) {
String result = search(argi[i], "\\b"+word+"\\b");
if (word == null || word.isEmpty()) {
str = "Enter a search word!";
}
else if(!word.matches("^\\w+$")){
str="Incorrect word!";
}
else if (result != null) {
str += "Search phrase " + "<b>"+ word + "</b>" + " have found in " + "<a href=\"" + argi[i] + "\">" + result + "</a>"+ "<p></p>";
}
else if (????????) {str="Word not found!";}
}
}
要我穿什麼在最後的「否則,如果」獲得「海峽=」字找不到!「如果我輸入要搜索輸入一些正常的字或數字,這是在內容不存在
沒有。只要把'else'。 – Maroun
爲什麼不只是沒有條件? – Kiwy
@Kiwy可能有我的評論的重複;) – Maroun