Advertisement
grodek118

Name List

May 13th, 2022
1,066
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4. import java.util.ArrayList;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.     public static void main(String[] args) {
  9.         Scanner scanner = new Scanner(System.in);
  10.         ArrayList<String> names = new ArrayList<>();
  11.  
  12.         System.out.println("Give names: ");
  13.         while (true) {
  14.             String input = scanner.nextLine();
  15.             if (input.equals("")) {
  16.                 break;
  17.             }
  18.             names.add(input);
  19.         }
  20.  
  21.         System.out.println(names.get(2));
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement