How to find the longest string in a list of strings in Scala

1 Answer

0 votes
val strings = List("c++", "scala", "python", "c#", "java")

val longestString = strings.maxBy(_.length)

println(longestString)



/*
run:

python

*/

 



answered Oct 2, 2024 by avibootz
edited Oct 2, 2024 by avibootz
...