0

I'm trying to find a solution for a programme which I'm writing. The problem occurs even though I tried to prevent it and I don't seem to be able to find a mistake. This is the ''problematic'' part of my code:

if (this.s != null) {
        if (s.s != null && s.s.sta.length != 0) {
            for (int n = x; n < s.s.sta.length + x; n++) {
                    this.sos[n] = s.s.sta[n-x];
            }
            x = x + s.s.sta.length;
        }
}

I have an array STA which I'm using and a method which gives me the ''s'' neighbour of an object, so s.s is a neighbour of a neighbour.. What I'm trying to do is copy the objects from more than one specific neighbour into one array with many different if sentences. This one is an example but it doesn't work. Thank you and I really hope I get some info because I'm completely lost.

1 Answers1

1

In the second line of your code you have:

if (s.s != null && s.s.sta.length != 0) {

You do check if s.s is null, but you do not check if s.s.sta is null.

Paul
  • 66
  • 3
  • I did that and it solves this problem but in the other part that is identical to this which I also fixed, it is still giving me the same error. – Neža Đukič Jan 01 '15 at 21:56