Answers for "how to find the longest string in the array of strings"

0

java get longest string in array

int index = 0; 
int elementLength = array[0].length();
for(int i=1; i< array.length(); i++) {
    if(array[i].length() > elementLength) {
        index = i; elementLength = array[i].length();
    }
}
return array[index];
Posted by: Guest on June-27-2021

Code answers related to "how to find the longest string in the array of strings"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language