0

I don’t understand how to initialize an array that is the class

ItemArray Is the class. I have to Initialize the size of the array (the array is the class) to be the size passed Into the constructor below. I don’t know how to do that though. public ItemArray(int size) {}

1st Sep 2019, 7:36 PM
Jamie Charles
2 Respuestas
+ 12
In the main method ItemArray obj = new ItemArray(/* pass your value */);
1st Sep 2019, 7:52 PM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar
+ 3
Do you mean something like this? public class ItemArray { //your variable int size; //your constructor public ItemArray(int size){ //this.size means your variable //int size is the variable from outside this.size = size; } }
1st Sep 2019, 7:54 PM
Denise Roßberg
Denise Roßberg - avatar