Bắt đầu ngayBắt đầu miễn phí

Maximum

You need to find the longest word of that label list to determine the size of the bubbles on the visual you are going to print.

Bài tập này là một phần của khóa học

Intermediate Java

Xem khóa học

Hướng dẫn bài tập

  • Give the appropriate type to wordsList.
  • Enter the fitting comparison to select the longer word.
  • Enter the correct method to find the longest word.

Bài tập tương tác thực hành trực tiếp

Hãy thử làm bài tập này bằng cách hoàn thành đoạn mã mẫu này.

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));
  }
}
Chỉnh sửa và Chạy Mã