Reputation:
I'm having an issue
TEST CODE:
addList.add("Task 30", 30);
System.out.println(addList.get
NOTE: For whatever reason the method actuallly using the exception has no compiler errors but the one that doesn't use it is. Why is that?
Upvotes: 2
Views: 47
Reputation: 83527
testAdd()
does not have any errors because you catch
the exception. testGet()
gives errors because you do not have a catch
nor do you declare that the method can throw
the exception. For more details about exceptions, read the official Java tutorial, particularly the section on catch or specify.
Upvotes: 1