Write a function that will return the second longest string in a list of strings. You have to do a single pass on the list.
Sigiloso
public int find2ndLongest(String[] strAry) { int max_1 = 0; int max_2 = -1; if (strAry == null || strAry.length == 0) { System.err.println(" Array is NULL or length is zero!!"); return -99; } if (strAry.length == 1) { System.err.println(" Array length is ONE. No Max 2!!"); return -99; } int i = 0; while (i strAry[max_1].length()) { max_2 = max_1; max_1 = i; } else { if (max_2 < 0 || strAry[max_2].length() < strAry[i].length()) max_2 = i; } i++; } //end while return max_2; }