提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
排序长型数组
import java.util.Arrays; public class Main { /** from * n o w j a v a . c o m **/ public static void main(String[] args) { //create long array long[] l1 = new long[]{3,2,5,4,1}; //print original long array System.out.print("Original Array :\t "); for(int index=0; index < l1.length ; index++) System.out.print(" " + l1[index]); /** 来自 nowjava.com - 时 代 Java**/ //To sort full array use sort(long[] l) method. Arrays.sort(l1); //print sorted long array System.out.print("\nSorted long array :\t "); for(int index=0; index < l1.length ; index++) System.out.print(" " + l1[index]); long[] l2 = new long[]{5,2,3,1,4}; Arrays.sort(l2,1,4); //print sorted long array