Let's change the way I am asking the question. For constructing an object in a class, we can also use some other variables. Consider this example:
public class Foo {
int X1;
int X2;
public Foo(int a) {
int[] array=new int[4];
// ...
}
}
If we create 2 objects of this class, we will have 2 variables per object and totally the memory will be occupied for 4 integer variables. My concern is the memory dedicated to the integer array defined inside the constructor. How the memory will be assigned when creating several objects?
Thanks,
Aucun commentaire:
Enregistrer un commentaire