0

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)));
2
Contributors
2
Replies
11
Views
3 Years
Discussion Span
Last Post by Doogledude123
0

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?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.