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() {
//write your code here
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
ArrayList<Integer> arr = new ArrayList<Integer>();
try{
arr.add(Integer.parseInt(b.readLine()));
}
catch(Exception e){
for (int i = 0; i < arr.size(); i++)
System.out.println(arr.get(i));
}
}
}
please what is wrong with the code
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
12 February 2019, 14:58
Your code only reads one number. It should continue reading numbers until text is entered instead of a number.
0