提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
生成排序数组
/* 来 自 n o w j a v a . c o m - 时 代 Java*/ //package com.nowjava; public class Main { public static void main(String[] argv) throws Exception { int length = 2; System.out.println(java.util.Arrays .toString(generateSortedArray(length))); } /** * generate sorted array */ public static int[] generateSortedArray(int length) { if (length <= 0) { return new int[] {};//来 自 N o w J a v a . c o m } int[] arr = new int[length]; int data = 1; for (