Array in JAVA
Using Of Array in JAVA with Example
Array is a container or a collection which has the similar kind of data types. Array is stored in contiguous memory. In JAVA, arrays behave as an object. We can find the length and do other manipulations using the in-build functions.
For using array in the JAVA program we have to declare an array using the int data type and not long or not short. Decleration of array can be done by,
- We ca access any array element randomly by using JAVA indexes provided by JAVA array.
- Primitive type to wrapper classes object conversion will not happen so it is fast.
- Array can store many number of elements at a time.
Disadvantages:
- Arrays are strongly typed.
- Arrays doesn't have add or remove method.
- We need to mention size of array, so it's length is fixed.
- We can't change the size of array at runtime.
Let us go through an example on the JAVA array which is used to store the data of 6 subjects(of your choice) mark and display the percentage of the student.
Comments
Post a Comment