Results 1 to 2 of 2
  1. #1
    bzupnick is offline Member
    Join Date
    Sep 2009
    Posts
    3
    Rep Power
    0

    Default 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 =)

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    Java 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.

Similar Threads

  1. Replies: 4
    Last Post: 01-04-2011, 12:36 AM
  2. compile errors (how do I fix)
    By rhythmiccycle in forum New To Java
    Replies: 4
    Last Post: 01-03-2011, 10:33 PM
  3. Compile Errors and need to add a second static
    By lk1001 in forum New To Java
    Replies: 5
    Last Post: 03-04-2010, 11:58 PM
  4. Help with Compile time errors
    By bri1547 in forum New To Java
    Replies: 2
    Last Post: 08-24-2008, 11:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •