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.
Here is code that works:
import java.util.Arrays;
import java.util.Collections;
public class Test
{
public static void main(String[] args)
{
orderedGuests1(new String[] { "c", "a", "b" });
orderedGuests2(new String[] { "c", "a", "b" });
}
public static void orderedGuests1(String[] hotel)
{
Arrays.sort(hotel);
System.out.println(Arrays.toString(hotel));
}
public static void orderedGuests2(String[] hotel)
{
Collections.sort(Arrays.asList(hotel));
System.out.println(Arrays.toString(hotel));
}
}