-1

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!

horHAY
  • 788
  • 2
  • 10
  • 23
  • 4
    If this code is generating a NPE, then `client` is `null`. (BTW, Why is `connections` being set "further up in the class and initialized" and also being set in the line you posted?) – Ted Hopp Apr 18 '14 at 20:28
  • 2
    post the full stacktrace of the NPE, to see where its coming from – Angular University Apr 18 '14 at 20:29
  • Guys, im incredibly sorry, i forgot to call my function to get client in the first place... how stupid - thanks for responding though!!! – horHAY Apr 18 '14 at 20:32

1 Answers1

1

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>).

Community
  • 1
  • 1
amit
  • 175,853
  • 27
  • 231
  • 333