标签:style java学习 arrays color har rgs nbsp 数值 system
一维数组的排序
使用Arrays.sort()对数组排序
适用于数值型数组 byte/char/short/int/long/float/double
public class Test { public static void main(String[] args) { int[] a = {15,67,51,34,12,99,13,65}; Arrays.sort(a); //for-each for (int i : a) { System.out.print(i + "\t"); } //for // for (int i = 0; i < a.length; i++) { // System.out.print(a[i] + "\t"); // } } }
适用于String型数组(暂时省略)
public class Test { public static void main(String[] args) { String[] b = {"zdfg","asf","ert","dfg","tyjy","cgef"}; Arrays.sort(b); //for-each for (String i : b) { System.out.print(i + "\t"); } } }
标签:style java学习 arrays color har rgs nbsp 数值 system
原文地址:http://www.cnblogs.com/lialong1st/p/7825576.html