I found an instantiation wich I do not understand how works. The instantiation looks like this:
public static Class instance[] = new Class[arraySize];
If my guessing is right, the instance is an array? How will this work?
I found an instantiation wich I do not understand how works. The instantiation looks like this:
public static Class instance[] = new Class[arraySize];
If my guessing is right, the instance is an array? How will this work?
This declares an array of Class
objects references. It is equivalent to the other syntax of []
after the type.
You would access it just like a normal array:
instance[0] = ...
instance[1] = ...
public static Class instance[] = new Class[arraySize];
public
is the access modifier. This one means that this variable is visible in your entire project
static
means that this variable is a "class" field it means that it belongs to the entire class and you can access it by ClassName.nameOfTheVariable
or if you are accessing it from inside of class it is declared you could use just nameOfTheVariable
.
Class
in this context is a type and you should treat is as a type of object
[]
means that this is an array you could also write Class[]
=
is assignment operator
new
is the word that annunciates that there will be memory allocation and constructor invokation after it
After new there is initialization of array of arraySize
length.