Reputation: 105
why do I need to import inputmismatchexception when I try
catch(InputMismatchException e){
System.out.println("cant print");
but when I try the following, I don't have to import anything?
catch(ArithmeticException e){
System.out.println("cant print");
Upvotes: 0
Views: 326
Reputation: 4135
why do I need to import inputmismatchexception
java.util.InputMismatchException
is in java.uti
package. You should import it Since its not imported by default.
java.util.InputMismatchException doc
I don't have to import anything?
java.lang.ArithmeticException
is in java.lang
package. You no need of importing this package Since its imported by default.
java.lang.ArithmeticException doc
java.lang
have the core java language classes.
Upvotes: 2