0
If the theory says that the size of an array cannot be changed, only the elements. Because when I print the size of a
the value is 10 and not 5 or 15?
int[] a;
a = new int[5];
a = new int[10];
0
If the theory says that the size of an array cannot be changed, only the elements. Because when I print the size of a
the value is 10 and not 5 or 15?
int[] a;
a = new int[5];
a = new int[10];
4
In the example you gave it should be borne in mind that a
is a pointer to an Array and not the Array itself.
So the moment you did a = new int[10]
the a
that previously pointed to an Array of size 5 now now points to the Array of size 10.
And what happened to Array size 5?
Once the array has no one pointing at you, it is ready to be displaced by the Garbage Collector.
1
You didn’t change the size of the vector, you instated it again with a larger vector size.
Browser other questions tagged java array java-processing
You are not signed in. Login or sign up in order to post.
Makes a lot of sense.
– find83