Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

ARRAYS

Array --> Array is a Non-Primitive Datatype, it is a container object that holds a


fixed number of values of a single type.

-->Types
1. Single Dimensional
2. Multi Dimensioanl(Two Dimensional, Jagged array)

int[] i=new int[5];


i[0]=5;
i[1]=8;
i[2]=4;
i[3]=5;

for(int j=0;j<=i.length;i++)
sysout(i[j]);

int sum=i[0]+i[1]+i[2]+i[3];

int i[]={6,8,9,3,6};

int arr[][]=new int[3][2];

for(int i=0;i<arr.length;i++)
int singleRow[]=arr[i];
for(int j=0;j<singleRow.length;j++)
sysout(singleRow[j]+" ")

sysoutln();

***********************************
to display values
for(int i=0;i<arr.length;i++)
for(int j=0;j<arr[i].length;j++)
sysout(a[i][j]+" ")

arr[i].length = will find lengths

***********************************************
to display the total count
int size=0;
for(int i=0;i<arr.length;i++)
size=size+arr[i].length;

sysout(size);

**********************************************
Jagged Array

int arr[]=new int[3][]


arr[]=new int[];
arr[]=new int[];
arr[]=new int[];

You might also like