import java.util.*; public class Exceptions extends Exception { int num; public Exceptions(int n) { num = n; } public void checkCard() { if(this.num > 5 || this.num <= 0) { System.out.println("An Incorrect input has been detected"); } } } ======================================================================================= import java.util.*; public class test { public static void main(String[] args) throws Exceptions { Scanner input = new Scanner(System.in); System.out.print("Enter numbers: "); String str1 = input.nextLine(); String[] str2 = str1.split(" "); ArrayList n = new ArrayList(); for(int i = 0; i < str2.length; i++) { int a = Integer.parseInt(str2[i]); throw new Exceptions(a); } } }