标签:new 数组 static 字典顺序 length pareto print style div
package ltb6w1; public class WordSort1 { private String[] a= {"hello","world","welcome","hi","hey"}; private int w; private int q; public WordSort1() { for(int i=0;i<a.length-1;i++) { for(int j=i+1;j<a.length;j++) { if(a[i].compareTo(a[j])>0) { w=i; q=j; getWordSort(a[i],a[j]); } } } } public void getWordSort(String ai,String aj) { String temp; temp=ai; a[w]=aj; a[q]=temp; } public void printSort() { for(String s:a) { System.out.print(s+" "); } } public static void main(String[] args) { WordSort1 ws=new WordSort1(); ws.printSort(); } }
标签:new 数组 static 字典顺序 length pareto print style div
原文地址:http://www.cnblogs.com/ltb6w/p/7819523.html