How does Java take the length of the shortest string
This article mainly introduces "how to take the length of the shortest string in Java". In daily operation, I believe many people have doubts about how to take the length of the shortest string in Java. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "how to take the length of the shortest string in Java". Next, please follow the editor to study!
The simplest way is to take one character at a time and judge whether it matches or not in turn. Each string can actually be optimized, giving priority to the critical value and taking the shortest string length. This way of thinking is clearer: public String longestCommonPrefix (String [] strs) {if (strs==null | | strs.length==0) {return ";} if (strs.length==1) return strs [0] Int minLen = strs.length+1; for (String str: strs) {if (minLen > str.length ()) {minLen = str.length ();}} for (int iTuno; I