X593: getMaxLength

This method takes an ArrayList of Strings as a parameter and returns the length of the longest String in the list. If the list is empty, the method should return 0. For example, if an ArrayList variable called list stores {"four", "and", "years", "ago"}, findMaxLength(list) should return 5.

Examples:

getMaxLength(new java.util.ArrayList(){{add("four");add("and");add("years");add("ago");}}) -> 5

Your Answer:

Reset

Practice a different Java exercise

Feedback

Your feedback will appear here when you check your answer.