0% found this document useful (0 votes)
1 views5 pages

Array

Java arrays are objects that store elements of the same data type in a contiguous block of memory, with a fixed size. They are index-based, allowing for efficient data retrieval and sorting, but have limitations due to their static size. There are two types of arrays in Java: single-dimensional and multidimensional.

Uploaded by

ipsitmahakul22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

Array

Java arrays are objects that store elements of the same data type in a contiguous block of memory, with a fixed size. They are index-based, allowing for efficient data retrieval and sorting, but have limitations due to their static size. There are two types of arrays in Java: single-dimensional and multidimensional.

Uploaded by

ipsitmahakul22
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Java Arrays

An array is typically a grouping of elements of the same kind that are stored in a single,
contiguous block of memory.

Java array is an object which contains elements of a similar data type. Additionally, The
elements of an array are stored in a contiguous memory location. It is a data structure
where we store similar elements. We can store only a fixed set of elements in a Java
array.

Array in Java is index-based, the first element of the array is stored at the 0th index, 2nd
element is stored on 1st index and so on.

Array is a class in java available in java.util package

Syntax:

datatype arrayRefVar=new datatype [size];


Advantages

o Code Optimization: It makes the code optimized, we can retrieve or sort the data efficiently.
o Random access: We can get any data located at an index position.

Disadvantages

o Size Limit: Arrays have a fixed size and do not grow dynamically at runtime

Types of Array in java

There are two types of array.

o Single Dimensional Array


o Multidimensional Array
Program Sum of Elements of array.

You might also like