Array index out of bound exception

时间:2017-06-22 20:50:41
【文件属性】:
文件名称:Array index out of bound exception
文件大小:423B
文件格式:RAR
更新时间:2017-06-22 20:50:41
java Write a program that first creates an integer array a[50], and set a[i] = i+3, i=0 to 49. The program next reads in an index k from the user, then calls a method readValue(int [ ] a, int k) that would return the value of a[k]. The main program displays the value a[k]. If the index is out of bounds, the method readValue(int [ ] a, int k) should throw an IndexOutOfBoundsException. The main program should catch the exception and display the message "out of bounds".
【文件预览】:
Main.java

网友评论