import?java.util.ArrayList;
import?java.util.Scanner;
public?class?JudgeString?{
public?static?void?main(String[]?args)?{//?接受键盘输入
Scanner?in?=?new?Scanner(System.in);
//?保存输入数据的List
ArrayList<String>?list?=?new?ArrayList<String>();
System.out.println("请输入字符串,输入“end”为结束:");
//?获取每次输入的字符串
String?temp?=?in.nextLine();
//?获取输入的所有字符串
while?(!temp.equals("end"))?{
list.add(temp); temp?=?in.nextLine();}
//?调用排序函数
sort(list);
//输入结果
System.out.println("排序后的结果为:");
for(int?i?=?0;i<list.size();i++){
System.out.println(list.get(i));}
} //?排序函数(冒泡) public?static?void?sort(ArrayList<String>?list)?{String?temp?=?"";
for?(int?i?=?0;?i?<?list.size();?i++)?{
for?(int?j?=?0;?j?<?list.size()?-?1;?j++)?{if?(list.get(i).compareToIgnoreCase(list.get(j))?>?0)?{
temp?=?list.get(i); list.set(i,?list.get(j)); list.set(j,?temp);}
}}
}}
已经调试过了,肯定能运行,有不懂得可以问