String[] theWords = {"hello", "good bye", "tomorrow"}
のような配列があるとします。私は、文字 'e'を持つ配列内のすべての文字列を削除/無視したい。それをどうやってやりますか?私の考えは次の通りです:Java:文字のために配列から項目を削除する
for (int arrPos = 0; arrPos < theWords.length; arrPos++) { //Go through the array
for (int charPos = 0; charPos < theWords[arrPos].length(); charPos++) { //Go through the strings in the array
if (!((theWords[arrPos].charAt(charPos) == 'e')) { //Finds 'e' in the strings
//Put the words that don't have any 'e' into a new array;
//This is where I'm stuck
}
}
}
私のロジックがうまくいくか、正しいトラックにいてもわかりません。どんな反応も役に立つでしょう。どうもありがとう。
に見:1)のArrayListはなく、アレイ、および2)文字列 '...(含有)'メソッドを使用して。 –
なぜ 'ArrayList'を使わないのですか?配列を使用する場合は 'contains'を使用して' character'や 'word'をチェックしてください –
ArrayListをまだ学習しておらず、配列はまだ比較的新しいです。 –