-->
当前位置:首页 > 题库

PROGRAMMING:Jmu-java-06 exception-02-handling exception input using exception mechanism

Luz5年前 (2021-05-10)题库452
Use exception handling input mechanism to make the program more robust.
###Main method:
1. Enter n to create an int array of size n.
2. Input n integers and put them into the array. When inputting, it is possible to input a non integer string. At this time, you need to output exception information and re-enter it.
3. Use 'arrays. ToString' to output the contents of the array.
###Input example:
```in
five
one
two
a
b
four
five
three
```
###Output example:
```out
java.lang.NumberFormatException: For input string: "a"
java.lang.NumberFormatException: For input string: "b"
[1, 2, 4, 5, 3]
```






answer:If there is no answer, please comment