セクション 3. 章 11
single
Challenge: Selecting Random Products Within a Category
メニューを表示するにはスワイプしてください
タスク
スワイプしてコーディングを開始
Imagine you have a list of products from an online store. Your goal is to group them by category, pick a random product from each group, and display the result.
- Group the list of products by
categoryusinggroupingBy(). - For each category (
productList), get the list of products using thestream()method and select a random product withfindAny(). - Check if the
Optionalcontains a value usingifPresent(). - If
Optionalhas a value, print the information in the following format:"Category: {category} => {product}".
解答
すべて明確でしたか?
フィードバックありがとうございます!
セクション 3. 章 11
single
AIに質問する
AIに質問する
何でも質問するか、提案された質問の1つを試してチャットを始めてください