Коллеги, привет.
Подскажите пожалуйста почему не прохожу валидатор?
package com.javarush.task.task14.task1420;
/*
НОД
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<Integer> list = new ArrayList<>();
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str1 = bf.readLine();
String str2 = bf.readLine();
int a = 0;
int b = 0;
try {
a = Integer.parseInt(str1);
b = Integer.parseInt(str2);
} catch (Exception e) {
System.out.println("NumberFormatException");
}
if (a < 0 || b < 0) {
System.out.println("less than 0");
throw new Negative();
} else if (a > b) {
for (int i = 1; i <= b; i++) {
if (a % i == 0 && b % i == 0) {
list.add(i);
}
}
} else if (a < b) {
for (int i = 1; i <= a; i++) {
if (a % i == 0 && b % i == 0) {
list.add(i);
}
}
}
int maximum = Collections.max(list);
System.out.println(maximum);
}
}
class Negative extends ArithmeticException {
}