Topics
Published on April 11, 2017 by kudvenkat
Want create site? Find Free WordPress Themes and plugins.

What is an array
1. Container that holds fixed number of values
2. All values are of single type
3. Length of Array is fixed during creation

Array Example
String[] args in main function

Declaring one dimensional array in java

int[] anArray; // declares an array of integers
char[] charArray; // declares character array

Another form of declaration

int anArray[];
char charArray[];

Initializing one dimensional array in java

int[] anArray = new int[10];
OR
int[] anArray;
anArray = new int[10]

Shortcut to initialization
int[] anArray = { 100, 200, 300, 400, 500 }

Multidimensional Array in Java
In a multidimensional array, each element is an array

int[][] matrix = new int[5][5];

int[][] matrix = {
{ 1, 0, 1},
{ 1, 1, 1},
{ 1, 1, 0}
};

Did you find apk for android? You can find new Free Android Games and apps.

Leave a Reply

3 Comments on "Arrays in java"

Notify of
avatar

deepak gupta
Guest
deepak gupta
6 months 5 days ago

hello sir,may you help me ,i want Retrieve multiple rows to multiple texbox in asp.net …plzzz help me give me code/ video or link

konda sai kumar
Guest
konda sai kumar
6 months 8 days ago

sir will u teach all Java technologies

RAQIBUL ALAM RASHED
Guest
RAQIBUL ALAM RASHED
6 months 10 days ago

Thanks from Bangladesh

wpDiscuz