207k views
2 votes
Why is an array like a list? How do you identify and find elements in an array? Explain the purpose of a try-catch block and give an example. (Intro-to-Java)

User Dimson D
by
4.8k points

1 Answer

6 votes

Answer:

Java supports creation and manipulation of arrays, as a data structure. The index of an array is an integer value that has value in interval [0, n-1], where n is the size of the array. If a request for a negative or an index greater than or equal to size of array is made, then the JAVA throws a ArrayIndexOutOfBounds Exception. This is unlike C/C++ where no index of bound check is done.

The ArrayIndexOutOfBoundsException is a Runtime Exception thrown only at runtime. The Java Compiler does not check for this error during the compilation of a program.

Step-by-step explanation:

User Muhammad Musavi
by
4.4k points