0
import java.util.ArrayList;
import java.util.Scanner;

public class ThirdElement {

    public static void main(String[] args) {
        Scanner name = new Scanner(System.in);
        ArrayList list = new ArrayList < > ();

        while (true) {
            list.add(name.nextLine());

            if (name.nextLine() == "") {
                break;
            }
        }
        System.out.println(list.get(2));
    }
}

I can't figure out how to get the while loop to break as well as print the desired "get" statement correctly.

0 Answers0