-
help with compile errors
heres my code:
/** * * @author Binny * */ public class Star
or
/**
*
* @author Binny
*
*/
public class Start {
public Start(int numberOfPlayers) {
List<Player> l = new List<Player>();
String[] playerNumber = {"Red", "Green", "Blue", "Yellow" ,"Orange", "Black", "Purple"};
for(int i = 0; i < numberOfPlayers; i++){
Player playerNumber[i] = new Player();
System.out.println(numberOfPlayers);
System.out.println(playerNumber[i]);
l.add(playerNumber[i]);
}
}
}
so the errors on line 11 says:
- Syntax error on token "i", delete this token
- Duplicate local variable playerNumber
- Type mismatch: cannot convert from Player to
Player[]
thanks in advance =)
-
Code:
Player playerNumber[i] = new Player();
This code duplicates the variable playerNumber. You should rename this variable. Since you don't post the Player code, we can't say if or how the array playerNumber relates to the Player object you are creating.