Professional Documents
Culture Documents
Presentation 1
Presentation 1
• What is ARRAY…?
• Need of ARRAY
• Accessing ARRAY
Elements
• Displaying ARRAY
• Length & index of AR RAY [ ]
ARRAY
• Multi-dimensional
ARRAY
• Reversing The
ARRAY
created by:
RITESH DEV
WHAT IS ARRAY…?
Array is a collection of similar types of data.
An array is a container object that holds a
fixed number of values of a single type.
The length of an array is established when
the array is created.
After creation, its length is fixed.
NEED OF ARRAY…
With a var. reference, a object is created.
Elements r stored in contiguous memory
blocks.
Accessing elements in an Array is faster.
ACCESSING ARRAY ELEMENT(S)
for loop:
SYNTAX:
for(int a=0; a<Arr.length; a++){
sysout(Arr[a]);}
for-each loop:
SYNTAX:
for(int e: Arr){
sysout(e);}
MULTI-DIMENSIONAL ARRAY -
SYNTAX:
int [][] Arr= new int [9][3];
REVERSING THE ARRAY-
SYNTAX:
int temp; int l= arr.length/2;
for(int a= 0; a<l; a++){
temp= arr[a];
arr[a]= arr[arr.length-1-a];
arr[arr.length-a-1]= temp;}
THANK U...!!!
For ur attention