Hi guys,
I've created three classes "Players_DB", "Print_DB" & "Server" which has the main method in it.
I'm trying to populate the array with objects created from the Players_DB class, the Players_DB class contains variables that contain player information.
Here's my server class
​package myPackage;
public class Server {
public static void main(String[] args) {
int Arr_Players_DB[] = new int [5]; //array object initialization
for (int i = 0; i < Arr_Players_DB.length ; i ++)
{
Arr_Players_DB[i] = -1; //Initialize array
}
for (int i = 0; i < Arr_Players_DB.length; i ++) // //populate array
{
Players_DB player = new Players_DB();
if (Arr_Players_DB[i] == -1)
{
Arr_Players_DB[i] = player;
}}}}
Players_DB class
package myPackage;
public class Players_DB {
public Players_DB()//Constructor
{
}
public int player_id;
public String player_Username;
public String player_Password;
public int x_pos;
public int y_pos;
public int room_x;
public int room_y;
}
Im getting the error "cannot convert from Players_DB to int" at this line
Arr_Players_DB = player;
From what I understand I cant store a class object inside of an array ?