Easy!
import java.util.ArrayList;
import java.util.Collections;
public class Main {
/**
* @param args
* the command line arguments
*/
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(int i = list.size(); i > 0; i--){
System.out.println(list.get(i-1) + " ");
}
}
}
----------------
Peter
John
Bill