Package Com.demo;
Import Java.util.Arrays;
Import java.util.List;
Import Java.util.TreeSet;
public class Sort {
Public static void Main (string[] args) {
integer[] data = new INTEGER[5];
for (int i=0;i<data.length;i++) {
Data[i] = i+1;
System.out.println ("the number added to the array is:" +data[i]);
}
System.out.println (Getsecond (data));
}
public static int Getsecond (integer[] data) {
list<integer> dataList = arrays.aslist (data);
treeset<integer> ts = new treeset<integer> (dataList);
return Ts.lower (Ts.last ());
}
}
Note: The Aslist method input is a generic variable-length parameter, the base type is not generic, that is, 8 basic types can not be used as a generic parameter, To be A generic parameter, you must use its corresponding wrapper type . In addition, theAslist method returns a list of immutable lengths, how long the array is, how long the list is converted to, and the lists that theAslist method returns cannot be List.add and list.remove.
What is the maximum value of a small array maximum?