本帖最后由 zl78365336 于 2013-12-3 14:13 编辑
怎样将ArrayList集合中的字符串按字典顺序倒序排列? 程序错在哪里?
-------------------------------------------------------
List<String> list = new ArrayList<String>();
---------------------------------------------------------------------------
- public static void sort(List<String> list){
- for(int x=0;x<list.size()-1;x++){
- for(int y=0;y<list.size()-x-1;y++){
- if(list.get(y).equalsIgnoreCase(list.get(y+1))<0)){
- int temp = list.get(y);
- list.get(y) = list.get(y+1);
- list.get(y+1) = temp;
- }
- }
- }
复制代码
|
|