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