package com.lding.sort; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; public class StringSort { public static void main(String[] args){ // List<String> lost=new ArrayList<String>(); list.add("orange"); list.add("blue"); list.add("yellow"); list.add("gray"); System.out.println("排序前:"); for(String s:list){ System.out.print(S+" "); } System.out.println(); Collections.sort(list); System.out.println("排序后:"); for(String s:list){ System.out.print(s+" "); } } }
List<String> list=new ArrayList<String>();
Collections.sort(list);