Ads

Tuesday, 10 October 2017

Array In Java || Types of Array in Java



Array In Java



What is Array?

⇛ An array is set of the element where same data type but different name.

⇛Array is always started from 'Zero'.

⇛It always follows the index.

⇛It is popular in dynamic memory allocation.

⇛ []   <-- Array dimension square bracket


Types of array in java,Java array,array in java,java jagged,Java single array

#1)Single Dimension Array:

A one dimension array is a collection of variables with one row and multiple columns or one column and multiple rows.

Syntax :-

Datatype arr_name[]=new datatype[size];

Example :

int a[]=new int[5];

#2)Multi-Dimension Array:

The muti-dimension array means the array of array.It represents a variable which has values in tabular form i.e in rows and columns.

Syntax:-

Datatype arr_name[][]=new Datatype[row][column];

Example:-

int Abc[][]=new Abc[2][2];

#3)Jagged Array:

The jagged array is an array whose elements are arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an "array of arrays." The following examples show how to declare, initialize, and access jagged arrays.

Syntax :

Datatype  arr_name[][]=new Datatype[row][];

Example :

int abc[][]=new abc[row][];

 

Post a Comment

Click Here