Solved Mysterious NPE?

Discussion in 'Plugin Development' started by gamerzap, Nov 2, 2012.

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

    gamerzap

    I'm getting strange NPE's in my code. Here's the relevant code:
    PHP:
    import java.util.Map//<-HERE
    And:
    PHP:
                    Team team = new Team((Playersenderargs[1]);
    And heres the Team class:
    PHP:
    package com.gmail.gamerzap;
    import java.util.Set;
    import org.bukkit.entity.Player;
    public class 
    Team {
        public 
    Set<Playerplayers;
        public 
    String name;
        public 
    Set<Playerpending;
        public 
    Team(Player pString n){
            
    players.add(p);
            
    name n;
        }
        public 
    void addPlayer(Player p){
            
    players.add(p);
        }
        public 
    void addPending(Player p){
            
    pending.add(p);
        }
    }
     
  2. Offline

    fireblast709

    Stacktrace?
     
  3. Offline

    nisovin

    Your 'players' and 'pending' variables in the Team class are not initialized (they're null).
     
  4. Offline

    fireblast709

  5. Offline

    Cirno

    I believe it's [.SYNTAX=JAVA][/.SYNTAX]
     
    jtjj222 and fireblast709 like this.
  6. Offline

    gamerzap

    Thanks, I was wondering how to do that. But that still doesn't help with my problem.

    EDIT: Oh wait, nvm, I didnt see the first two posts.

    Thanks, I forgot to initialize them in the Team class.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
Thread Status:
Not open for further replies.

Share This Page