PROGRAMMING:Jmu-java-06 exception-01-common exception
Code yourself to generate common exceptions.
###Main method:
1. Define an array of 5 in advance.
2. Generate corresponding exception according to screen input
**Tip: * * you can use ` system. Out. Println (E) 'to print the information of the exception object, where e is the captured exception object.
**Input Description:**
1. ` arr 'represents an exception generated when an access array is generated. Then enter * * subscript * *. If an 'ArrayIndexOutOfBoundsException' exception is thrown, it will be displayed. If no exception is thrown, it will not be displayed.
2. "Null" generates a "NullPointerException."`
3. Try to convert the string object into an integer object to generate 'ClassCastException'.
4. Enter the character "num" and convert it to integer. If an "numberformatexception" exception is thrown, it will be displayed.
5. Others, end the procedure.
###Input example:
```in
arr 4
null
cast
num 8
arr 7
num a
other
```
###Output example:
```out
java.lang.NullPointerException
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
java.lang.ArrayIndexOutOfBoundsException: 7
java.lang.NumberFormatException: For input string: "a"
```
answer:If there is no answer, please comment
###Main method:
1. Define an array of 5 in advance.
2. Generate corresponding exception according to screen input
**Tip: * * you can use ` system. Out. Println (E) 'to print the information of the exception object, where e is the captured exception object.
**Input Description:**
1. ` arr 'represents an exception generated when an access array is generated. Then enter * * subscript * *. If an 'ArrayIndexOutOfBoundsException' exception is thrown, it will be displayed. If no exception is thrown, it will not be displayed.
2. "Null" generates a "NullPointerException."`
3. Try to convert the string object into an integer object to generate 'ClassCastException'.
4. Enter the character "num" and convert it to integer. If an "numberformatexception" exception is thrown, it will be displayed.
5. Others, end the procedure.
###Input example:
```in
arr 4
null
cast
num 8
arr 7
num a
other
```
###Output example:
```out
java.lang.NullPointerException
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
java.lang.ArrayIndexOutOfBoundsException: 7
java.lang.NumberFormatException: For input string: "a"
```
answer:If there is no answer, please comment