+ 1

How to make object array ?

26th Nov 2016, 11:08 AM
Suraj Anbhule
Suraj Anbhule - avatar
6 odpowiedzi
+ 18
int [] arr = new int [4]; Where int is the type of objects of the array arr is the name of array
26th Nov 2016, 11:43 AM
Remmae
Remmae - avatar
+ 1
Object[] array = new Object[10];
26th Nov 2016, 12:22 PM
Roland
0
by objects array you mean an array stores objects then you should use array list!
28th Nov 2016, 2:54 AM
Henok
Henok  - avatar
0
As others have said to make an array it's: int[] array = new int [3]; However if you know exactly what you want in the array you can initialize the elements from the start: int[] array = {0, 1, 2}; You can also have multidimensional arrays: int [][] array = new int [2][3];
5th Dec 2016, 6:34 PM
Bryan
Bryan - avatar
- 1
Class buy { String name ; int size ; Double price ; Public buy (String n , int s , Double p){ This.name =n ; This.size = s ; This.price =p; } Public String Tostring (){ Return ,,,,,,,, ; } Public class mainarray{ Public static void main (String[]args){ buy [ ] arrayA = {new buy ("water",1,0.5)}; }}
26th Nov 2016, 1:38 PM
amash
amash - avatar
- 2
this one is multi dimensional array. int [][] MultiArray={{1,2,3},{6,5,4}}; system.out.println([0],[1]); output: 2
26th Nov 2016, 12:26 PM
Carlo Palermo Mamuric
Carlo Palermo Mamuric - avatar