Array in java
One dimensional array:
Declaration of one dimensional array:
type variable_name[];
int test[] ; or int[] test;
Memory Allocation:
test = new int[5];
Or in one step
int test[] = new int[4];
or int test[] = {12, 33,33,66}
Array length: int a = test.length;
Two dimensional array
int test[][]; int [][] test;
test = new int[2][4];
int test [][] = new int[2][4];
array length of two D array
int row = test.length;
int columns = test[i].length;
Declaration of one dimensional array:
type variable_name[];
int test[] ; or int[] test;
Memory Allocation:
test = new int[5];
Or in one step
int test[] = new int[4];
or int test[] = {12, 33,33,66}
Array length: int a = test.length;
Two dimensional array
int test[][]; int [][] test;
test = new int[2][4];
int test [][] = new int[2][4];
array length of two D array
int row = test.length;
int columns = test[i].length;
Comments
Post a Comment