Java Array 1-Dimensional

Array – An array is an indexed collection of a fixed number of homogeneous data elements.
1. Instead of creating multiple int, float variable, we can assign into 1 called an Array
2. Array size is fixed. If we assigned 10000 and at runtime only 2 comes then 99998 space is wasted or vice-versa. Do we must know the size in advance if we want to use an array.
3. An array can contain the only same type of data types. This problem has come over in collection concept.

1. At the time of array creation, we should mention the size of the array
2. It is illegal to have array size 0 in java
3. The runtime exception will come if you pass negative size array.
4. Byte, short, char, it is allowed to specify the size of the array.
5. Maximum allowed array size in Java 2147483647 which is max value of int data type

Leave a Reply

Your email address will not be published. Required fields are marked *