JAVA List 대상 정렬

891 단어
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Rank implements Comparator{
	public static void main(String[] args) {
		 List<String> timList=new ArrayList<String>();
		 timList.add("9");
		 timList.add("4");
		 timList.add("1");
		 timList.add("6");
		 Rank rank=new Rank();
		 Collections.sort(timList,rank);
		 for (int i = 0; i < timList.size(); i++) {
			String orderString=timList.get(i);
			System.out.println(orderString);
		}
		 
	}
	public int compare(Object arg0, Object arg2) {
		String tString=(String) arg0;
		String tString2=(String) arg2;
		int flag=tString.compareTo(tString2);
		return flag;
	}
}

좋은 웹페이지 즐겨찾기