Ok, so what happens when you do this.
A a1=new A();
A a2=new A();
A a3=new A();
I upload two pictures on how I imagine it being like. Can you
This is a variable declaration;
A a1;
You declare a new variable called a1
of type A
.
a1 = new A();
You assign to a1
the value that results from new A()
, which is a new object of type A
.
You can do both things at once as an initialization:
A a1 = new A();
Each time you call your class constructor, you get a different and separated instance of your class. No instances know about the others, they lie in different regions of memory.
By the way, those are very very basics of programming, so get a good reading and happy learning.