最大值
您需要在该标签列表中找到最长的单词,以此确定您将要打印的可视化中气泡的大小。
本练习是课程的一部分
Java 中级
练习说明
- 为
wordsList提供合适的类型。 - 输入合适的比较,以选出更长的单词。
- 输入正确的方法,用于找到最长的单词。
交互式实操练习
通过完成这段示例代码来试试这个练习。
class LongestFinder {
// Give the appropriate type to wordsList
static String findLongestIn(____ wordsList) {
String longest = "";
for (String word : wordsList) {
// Enter the fitting comparison to select the longer word
if (____)
longest = word;
}
return longest;
}
public static void main(String[] args) {
String[] words = {"possible", "first", "null", "avoidance", "mineral", "pretty", "tree", "rather", "innocuous"};
// Call the correct method to find the longest word
System.out.println(____(words));
}
}