日期:2014-05-20 浏览次数:20743 次
//用TreeSet可以自然排序呀 不就是升序了么? 如: package com.testClass; import java.io.IOException; import java.util.Iterator; import java.util.Set; import java.util.TreeSet; public class Test2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws Exception { String time[] = {"2011/02/12 10:00~12:00","2011/03/12 13:00~15:00","2011/05/21 16:00~18:00","2010/12/07 19:00~21:00"}; Set<String> set = new TreeSet<String>(); for (int i = 0; i < time.length; i++) { set.add(time[i]); } Iterator<String> iterator = set.iterator(); while(iterator.hasNext()){ System.out.println(iterator.next()+"\n"); } } }