[Solved] Find the longest string


We can do this in two lines of code:

List<String> list = Arrays.asList(letterlist);
String longest = Arrays.stream(letterlist).max(Comparator.comparingInt(String::length)).get();

Demo

Inspired by this Code Review question:

https://codereview.stackexchange.com/questions/75807/finding-the-longest-string-and-its-length-using-java-streams

0

solved Find the longest string