I have a program which has the user inputs a list of names. I have a switch case going to a function which I would like to have the names print off in alphabetical order.
The first thing you tried seems to work fine. Here is an example program.
Press the "Start" button at the top of this page to run it to see the output yourself.
import java.util.Arrays;
public class Foo{
public static void main(String[] args) {
String [] stringArray = {"ab", "aB", "c", "0", "2", "1Ad", "a10"};
orderedGuests(stringArray);
}
public static void orderedGuests(String[] hotel)
{
Arrays.sort(hotel);
System.out.println(Arrays.toString(hotel));
}
}