+ 3
How to do arrays
6 Answers
+ 20
It is preferred in java to put [] before the name of your array. So it becomes
int [ ] arr =new int [n] ;
+ 4
a girl got 8 likes for her answer. Everyone else got a maxmimum of 2.LOL . Community, looking for girls or coders?
+ 2
if you want to insert values into the array by yourself, then you can do so as follows
int[ ] array = {10 , 2 , 1 , 4 , 5 , 100 , 1000 };
in above example no need to describe the elements of arrays by using ( new int[ 7 ]; )....
As describe by other other fellows above....
and also you can use either
int [ ] array;
or
int array[ ];
now if you want to use new keyword...
int array[ ] = new int [ 10 ];
:-):-):-):-)
0
int arr [] = new int [n];
n is the number of element of the array
you can choose the type of the array, including objects
0
datatype arrayname[]=new datatype[SIZE];
datatype-indicates type of array
size- indicates the no'of elements you needed.
0
Listen array is collection of similar types of elements. So example ; int ={10,11,52,45,28,69} collection of integer value if you add float value that is not array.