classes

Discussion in 'Plugin Development' started by Roan1, Mar 10, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    Roan1

    Code:
    ...
    memoryTeams[] goldteammemory;
    ...
    if(cmd.getName().equalsIgnoreCase("cmd")){
                goldteammemory = new memoryTeams[args.length];
                for(int i=0;i<args.length;i++) {
                    goldteammemory[i].team = new Team().gold;//Error in this
                    goldteammemory[i].nickname = args[i];//and this lines.
                }
                return true;
            }
    Code:
    public class Team {
        Team gold;
        Team undef;
    }
    Code:
    public class memoryTeams {
        Team team = new Team().undef;
        String nickname;
    }
    
     
  2. Offline

    zachoooo

    Thanks for your advanced and thorough description on what was wrong...
     
    Chipmunk9998 likes this.
  3. Offline

    Roan1

    Alright. How to fix this error?
     
  4. Offline

    zachoooo

    Well you never specified a real error, but one problem I see here is this... i<args.length, it should be i>args.length, because i will never be less than args.length, only equal to or greater than...
     
  5. you'll not even get into the loop if you change it to yours. when you do a for loop through an array, the index must be smaller than the actual size of the array at any time. So it's totally correct there.
     
  6. Offline

    zachoooo

    Sorry I just derped there.
     
Thread Status:
Not open for further replies.

Share This Page