Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

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
Comment

PREVIOUS NEXT
Code Example
Java :: access activity method from adapter 
Java :: spigot execute command as player 
Java :: Java Using forName() method 
Java :: java program to find perimeter of rectangle 
Java :: dupplicate classes android 
Java :: How to efficiently find the highest power of 2 dividing a given number, in Java? 
Java :: how to convert outputstream to bytearrayoutputstream in java 
Java :: how to move from one activity to another in android studio on button click 
Java :: java do while schleife 
Java :: char cannot be converted to string 
Java :: find if a value is in a 2d array java 
Java :: install java 8 arch 
Java :: change drawable color programmatically android 
Java :: char equals java 
Java :: iterator for array java 
Java :: java 2d array loop 
Java :: add to array function java 
Java :: eval in java 
Java :: font parameters java 
Java :: java negative infinity 
Java :: int to enum java 
Java :: solid principles in programming 
Java :: @data lombok 
Java :: convert int to string java 
Java :: java random unique key 
Java :: make frame visible java 
Java :: priority queue java comparator lambda 
Java :: java example 
Java :: android studio, not loading url in webview 
Java :: Cannot invoke toString() on the primitive type int 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =