7. Unit III Task Four training: Method SetID can set a value for a class's properties: ID (ID number), when given a value of length of 18 o'clock, assigned to the ID, the duty length is not 18 o'clock, throw illegalargumentexception exception. To capture and handle exceptions in the main method, write programs to achieve these functions.
The public class Test {
private String id;//ID number should be the length of public
void SetId (String id) {
if (id.length () = =) {
//determine if the length of the ID number is
this.id = ID;
} else {
throw new IllegalArgumentException ("The parameter length should be 18.") "); Throw exception
}
} public
static void Main (string[] args) {
test te = new test ();
try {
Te.setid ("0123456789123456789");
} catch (IllegalArgumentException IE) { //capture and handle exceptions
System.out.println (Ie.getmessage ());
} finally{
System.out.println ("End");}}