セクション 2. 章 3
single
Challenge: Names Starting with Letter B
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
Your task is to write a sortNamesStartWithLetterB method that will return only the names from this array names that starts with the letter B.
- Loop through the array and count how many names start with the letter
B. - Use the
charAt()method to extract the first letter of each name and compare it to the letterB. - Make sure you are checking for the uppercase letter 'B'.
- After counting, set the size for the new result array.
- Initialize the index variable, which will be used as the index for the result array.
- Loop through the array again and add names starting with
Bto the new array. - Increment the index each time you add an element to the new array.
- Return the new array with the names.
- In the main method, call the
sortNamesStartWithLetterBmethod.
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 2. 章 3
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください