This is correct.
A[] a = new A[4];
...creates 4 A references, similar to doing this:
A a1;
A a2;
A a3;
A a4;
Now you couldn't do a1.someMethod() without allocating a1 like this:
a1 = new A();
Similarly, with the array you need to do this:
a[0] = new A();
...before using it.
Answer from MeBigFatGuy on Stack OverflowCreating an array of objects in Java - Stack Overflow
Is an Array an Object?
How to initialize an array of objects in Java - Stack Overflow
Java Beginner - How do I create an object with classes that I can index !
Videos
This is correct.
A[] a = new A[4];
...creates 4 A references, similar to doing this:
A a1;
A a2;
A a3;
A a4;
Now you couldn't do a1.someMethod() without allocating a1 like this:
a1 = new A();
Similarly, with the array you need to do this:
a[0] = new A();
...before using it.
This is correct. You can also do :
A[] a = new A[] { new A("args"), new A("other args"), .. };
This syntax can also be used to create and initialize an array anywhere, such as in a method argument:
someMethod( new A[] { new A("args"), new A("other args"), . . } )
So, it's like how you create a constructor method and make an Object with it?
Also, is it possible to create Objects outside of main()? Are you able to can?
It is almost fine. Just have:
Player[] thePlayers = new Player[playerCount + 1];
And let the loop be:
for(int i = 0; i < thePlayers.length; i++)
And note that java convention dictates that names of methods and variables should start with lower-case.
Update: put your method within the class body.
Instead of
Player[PlayerCount] thePlayers;
you want
Player[] thePlayers = new Player[PlayerCount];
and
for(int i = 0; i < PlayerCount ; i++)
{
thePlayers[i] = new Player(i);
}
return thePlayers;
should return the array initialized with Player instances.
EDIT:
Do check out this table on wikipedia on naming conventions for java that is widely used.