Answers for "java get longest string in array"

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 "java get longest string in array"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language