Shreyas arya

Generation

generate functionFri, 10 Feb 2023

Create a method to throw an exception if does not print a string

public static void printNum (int number) throws Exception { if (number < 0) { throw new Exception("Number can't be less than zero"); } else { System.out.println("Number is " + number); } }

Questions about programming?Chat with your personal AI assistant