我真的很困擾這個問題的一部分。我一直在觀看視頻幾個小時,並在網上進行研究,但我似乎無法正確理解。我需要生成一個for循環來檢查字符串是否爲meg,並將其移除並移動剩餘的元素。這不是一個數組列表。從數組中刪除重複的字符串
寫第二,傳統的for循環來檢查字符串「 梅格 」各自 元件,如果 陣列中找到,將其刪除,移位剩餘元素,並顯示名稱的數組。
我知道我的循環會在我的最後一個客戶名稱&之間用於打印它。我只是對接下來要做的事感到困惑。
這裏是我當前的代碼:
public class CustomerListerArray {
public static void main(String[] args) {
String customerName[] = new String[7];
customerName[0] = "Chris";
customerName[1] = "Lois";
customerName[2] = "Meg";
customerName[3] = "Peter";
customerName[4] = "Stewie";
for (int i = customerName.length - 1; i > 3; i--) {
customerName[i] = customerName[i - 2];
}
customerName[3] = "Meg";
customerName[4] = "Brian";
for (String name: customerName) {
System.out.println(name);
}
}
}
'equalsIgnoreCase' ?? – sam
@ sam2090在關於不區分大小寫的搜索的問題中沒有任何內容,但是如果需要,這當然可以完成。 – dave
其實nvm。發現我做錯了什麼。 – BlueJay