Answers for "java find longest word in a string"

1

find shortest string in array java

public static String smallest(String words[]) {
    if (words == null || words.length < 1) {
        return "";
    }
    String smallest = words[0];
    for (int i = 1; i < words.length; i++) {
        if (words[i].length() < smallest.length()) {
            smallest = words[i];
        }
    }
    return smallest;
}// smallest
Posted by: Guest on July-08-2020

Code answers related to "java find longest word in a string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language