Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.InputMismatchException;
- import java.util.ArrayList;
- import java.util.Scanner;
- class Main {
- static ArrayList<Object> list = new ArrayList<>();
- static Scanner scanner = new Scanner(System.in);
- static int x;
- public static void main(String[] args) {
- try {
- while (scanner.hasNext()) {
- input();
- if (x == 0) {
- break;
- }
- }
- } catch (InputMismatchException e) {
- input();
- }
- list.forEach(System.out::println);
- }
- public static void input() {
- try {
- while ((x = scanner.nextInt()) != 0) {
- list.add(x * 10);
- }
- } catch (InputMismatchException e) {
- list.add("Invalid user input: " + scanner.next());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment