Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package listtest;
- /**
- *
- * @author RubenLaptop
- */
- import java.util.List;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class ListTest {
- public static void main(String[] args) {
- String itemOne;
- String itemTwo;
- Scanner userInput = new Scanner (System.in);
- List<String> groceryList = new ArrayList<>();
- System.out.println("Please enter in a grocery list item:");
- groceryList.add(itemOne = userInput.next());
- System.out.println("Please enter a second entry:");
- groceryList.add(itemTwo = userInput.next());
- System.out.println("The second item on the list is "+groceryList.get(1)+".");
- System.out.println("The first item on the list is "+groceryList.get(0)+".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement