質問

I have a function to return an arraylist;

public ArrayList sendUpdatedList()
{
    return connections;
}

this is how im calling it, from a different class;

connections = client.sendUpdatedList();

Its producing a nullpointererror. "connections" is set further up in the class and initialized. help!

役に立ちましたか?

解決

Since the only actual access to a reference here is client, then in here the problem is client is null.

Your stacktrace could actually have shown you that the method you thought is responsible, is not actually called.

As a side note, you should avoid using raw types (ArrayList), and try to stick with generics (ArrayList<SomeClass>).

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top