I am getting a NPE on a. I have no idea why the array would be null, but heres the relevent code for it.

public void setAbility(Ability[] abilities)
    {
        for(Ability a : abilities)
        {
            sb.append(a.getName());
        }
        pAbility.setText(sb.toString());
    }

Method called here:

        Pokemon sPokemon = Pokemon.getPokemon(sender.getValue());
        ...
        pController.setAbility(sPokemon.getAbility());

Passed getAbility():

public Ability[] getAbility()
    {
        return ability;
    }

ability:

private Ability[] ability;

Being set through constructor here:

public Pokemon((unrelevent), Ability[] ability, (unrelevent))
    {
        (unrelevent)
        this.ability = ability;
        (unrelevent)
    }

example constructor call:

pokemonList.add(bulbasaur = new Pokemon((unrelevent), new Ability[] {Ability.overgrow}, (unrelevent)));

Recommended Answers

All 2 Replies

I didn't see why that would fail, but have you tried printing ability at each of those stages to see where the null creeps in?

I found it... -.-

I was initializing them after I was initializing Pokemon.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.