방법1
Arrays.sort(UrlData.URLSName, new Comparator<Object>() {
public int compare(Object o1, Object o2) {
String t1 = (String) o1;
String t2 = (String) o2;
int re = t1.compareTo(t2);
return re;
}
});
방법2
ArrayList<String> alurlname = new ArrayList<String>();
Collections.sort(alurlname);//정렬
Collections.reverse(alurlname);//반대로 정렬
방법3
static void bubbleSort(String[] p_array) throws Exception {
boolean anyCellSorted;
int length = p_array.length;
String tmp;
for (int i = length; --i >= 0;) {
anyCellSorted = false;
for (int j = 0; j < i; j++) {
if (p_array[j].compareTo(p_array[j + 1]) > 0) {
tmp = p_array[j];
p_array[j] = p_array[j + 1];
p_array[j + 1] = tmp;
anyCellSorted = true;
}
}
if (anyCellSorted == false) {
return;
}
}
}for문 돌려서 순서대로 비교할 일은 없을꺼 같네
'JAVA' 카테고리의 다른 글
서버 확인후 메시지 보내기 (0) | 2014.10.20 |
---|---|
java 이미지 바이트 조합 (0) | 2014.01.09 |
자바 한글 있나 확인하기 (java string 한글 영어 구분) (0) | 2011.12.01 |
extra operand `/nologo' 에러 (0) | 2011.07.15 |
java 폴더 파일 명과 디렉토리 명 뽑아오기 (0) | 2011.06.24 |