We have a program that takes a string of comma-separated integers as input and attempts to convert it into a list of integers.
- If any of the values in the input string are not valid integers, the program should catch the exception and print the following message:
Invalid input! - If the list is empty, the program should throw
IllegalArgumentException, and then, when catching it, it should print the following message:Cannot calculate average of an empty list! - If all values are valid integers, the program should calculate the average of the list.
- If an unexpected error is caught, the program should print:
An error occurred!
Complete the catch block to handle all exceptions as intended.