I am hungry!
Given a List of String named foodList, add another element to the List, and then print the List in alphabetical order.
Use a method to add "Salad" to the list
Use a method to sort the List
Print the List to the console
import java.io.*;
import java.util.*;
public class CodingQuestion {
public static void main(String[] args) {
List<String> foodList = new ArrayList<>();
foodList.add("Cheeseburger");
foodList.add("Veggie Burger");
foodList.add("Fries");
foodList.add("Soda");
foodList.add("Onion Rings");
foodList.add("Milkshake");
/***** DO NOT CHANGE THE CODE ABOVE THIS LINE *****/
// WRITE YOUR CODE HERE
}
}
STDOUT
Expected STDOUT
[Cheeseburger, Fries, Milkshake, Onion Rings, Salad, Soda, Veggie Burger]