12

package arraylistlearning;

import java.util.*;

public class StringLister {
String[] namesy = { "Spanky", "Alfalfa", "Buckwheat",
"Daria","Stymie", "Marianne", "Scotty", "Tommy",
"Chubby" };

public StringLister(String[] moreNames) {
ArrayList<String> list = new ArrayList<String>();
for (int i = 0; i < namesy.length; i++) {
list.add(namesy[i]);
}
for (int i = 0; i < moreNames.length; i++) {
list.add(moreNames[i]);
}
Collections.sort(list);//排序算法
for (String name : list) {
System.out.println(name);
}
}

public static void main(String[] arguments) {
StringLister lister = new StringLister(arguments);
}
}

posted on 2017-03-11 21:42  tuzhuo  阅读(88)  评论(0编辑  收藏  举报