Skip to content
Advertisement

how to throw an exception to the main method consist of arraylist? [closed]

/Create a method namely callMethod in which display all countries from the arraylist,If more than 5 countries,the method will throw an exception to the main() method/

import java.util.Arrays;

import java.util.List;

import java.util.ListIterator;

public class Countries {

JavaScript

}

Advertisement

Answer

Define your method with something like

JavaScript

you can catch the error by wrapping callMethod invocation call with try{...}catch(){}

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement