发布网友 发布时间:2024-03-15 11:52
共1个回答
热心网友 时间:2024-12-15 02:32
public static void main(String args[])追答public static void main(String args[])
{
String target="John Bill Peter ";
ArrayList list=new ArrayList();
for(String temp:target.split(" "))
{
list.add(temp);
}
Collections.sort(list);
for(String temp:list)
{
System.out.print(temp+" ");
}
System.out.println();
Collections.reverse(list);
for(String temp:list)
{
System.out.print(temp+" ");
}
}