public class Solution {
public static void main(String[] args) {
readData();
}
public static void readData() {
//напишите тут ваш код
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
List<Integer> list = new ArrayList<>();
try {
while (true) {
int number = Integer.parseInt(reader.readLine());
list.add(number);
}
}
catch (IOException a)
{
System.out.println(a);
}
catch (NumberFormatException exception)
{
System.out.println(exception);
}
finally {
for (int a: list
) {
System.out.println(a);
}
}
}
}package com.javarush.task.task09.task0921;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/*
Метод в try..catch
*/
public class Solution {
public static void main(String[] args) {
readData();
}
public static void readData() {
//напишите тут ваш код
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
List<Integer> list = new ArrayList<>();
try {
while (true) {
int number = Integer.parseInt(reader.readLine());
list.add(number);
}
}
catch (IOException a)
{
System.out.println(a);
}
catch (NumberFormatException exception)
{
System.out.println(exception);
}
finally {
for (int a: list
) {
System.out.println(a);
}
}
}
}