Could someone tell me what I am doing wrong?
I am outputting the ArrayList items in a new line.
package com.codegym.task.task09.task0921;
import javax.imageio.IIOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
/*
Method in a try-catch
*/
public class Solution {
public static void main(String[] args){
try{
readData();
}
catch(Exception e){
e.printStackTrace();
}
}
public static void readData() throws Exception {
//write your code here
ArrayList<Integer> list = new ArrayList<Integer>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
try {
while(true){
int s = Integer.parseInt(reader.readLine());
list.add(s);
}
}
catch (IIOException e){
for(int i= 0; i < list.size();i++){
System.out.println(list.get(i));
}
e.printStackTrace();
}
}
}