java - Variables in Main Class -
so programming game war, , need put of methods in main class. having trouble initializing variables due errors.
public class main { public player<card> player1 = new player<card>(); public player<card> player2 = new player<card>(); public player<card>[] players = new player[2]; players[0] = player1; players[1] = player2; public static void main(string[] args) { } }
in lines of code, after make array, error says: "multiple markers @ line
type safety: expression of type player[] needs unchecked conversion conform player[]
syntax error on token ";", { expected after token"
the player class extending stack of type card. suggestions welcome.
thanks.
statements such
players[0] = player1; players[1] = player2;
can't done outside of method or constructor.
you can put them in constructor :
public main () { players[0] = player1; players[1] = player2; }
Comments
Post a Comment