It is also displaying as mentioned the output.What's wrong then ?
package com.codegym.task.task09.task0921;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Method in a try-catch
*/
public class Solution {
public static void main(String[] args) {
readData();
}
public static void readData() {
System.out.println("Starting readData method in few secs...");
ArrayList<Integer> password = new ArrayList<>();
try {
Thread.sleep(1000);
System.out.println("\n Now go ahead...");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
int YourInput;
while (true)
{
YourInput = Integer.parseInt(bufferedReader.readLine());
password.add(YourInput);
}
}
catch (Exception e)
{
for (int i: password
) {
System.out.println(i);
}
System.out.println(e);
}
}
}