What is the maximum value of a small array maximum?

Source: Internet
Author: User

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?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.