+ 1
How to make object array ?
6 Respostas
+ 18
int [] arr = new int [4];
Where int is the type of objects of the array
arr is the name of array
+ 1
Object[] array = new Object[10];
0
by objects array you mean an array stores objects then you should use array list!
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];
- 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)};
}}
- 2
this one is multi dimensional array.
int [][] MultiArray={{1,2,3},{6,5,4}};
system.out.println([0],[1]);
output: 2