+ 3

How to do arrays

12th Nov 2016, 1:53 AM
Derek Spurgeon
Derek Spurgeon - avatar
6 Respostas
+ 20
It is preferred in java to put [] before the name of your array. So it becomes int [ ] arr =new int [n] ;
12th Nov 2016, 5:25 AM
Remmae
Remmae - avatar
+ 4
a girl got 8 likes for her answer. Everyone else got a maxmimum of 2.LOL . Community, looking for girls or coders?
12th Nov 2016, 2:48 PM
Sandeep Balachandran
Sandeep Balachandran - avatar
+ 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 ]; :-):-):-):-)
12th Nov 2016, 6:53 AM
Adil Waheed
Adil Waheed - avatar
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
12th Nov 2016, 4:35 AM
Maurizio Urso
Maurizio Urso - avatar
0
datatype arrayname[]=new datatype[SIZE]; datatype-indicates type of array size- indicates the no'of elements you needed.
12th Nov 2016, 6:14 AM
Manikanta Pilla
Manikanta Pilla - avatar
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.
25th Nov 2016, 2:30 PM
Suryanarayan Behera
Suryanarayan Behera - avatar