0

I am trying to create an array of an object inside a class. Unfortunately I am keep running into nullpointerexception. This is my code, what could be wrong?

/////Init Buttons/////
    // 
    button[] Buttons=new button[nButtons];
   for (int i=0; i<nButtons-1; i++)
      Buttons[i]=new button();
    /////End/////  
    /////Set Button information/////  
    for (int n=0; index < nButtons*4-1; index+=4, n++) {

      ////////
      if (debug)
        print("Index ");
        println(index);
        print("N ");
        println(n);
      ////////   

      String[] pieces = split(lines[0], ' ');

      ////////
      if (debug)
      {
        print("Button name ");
        println(pieces[index]);
        print("Button X ");
        println(pieces[index+1]);
        print("Button Y ") ;
        println(pieces[index+2]);
        print("Button size ");
        println(pieces[index+3]);
      }
      ///////

      Buttons[n].setInfo(pieces[index], Float.parseFloat(pieces[index+1]), Float.parseFloat(pieces[index+2]), Float.parseFloat(pieces[index+3]));
    } 
Antu mArk
  • 1
  • 2
  • 1
    It would be helpful if you indicated *where* the exception occurs. If you're not sure, use your debugger. – Tieson T. Nov 01 '16 at 17:29
  • Buttons[n].setInfo(pieces[index], Float.parseFloat(pieces[index+1]), Float.parseFloat(pieces[index+2]), Float.parseFloat(pieces[index+3])); Here. Debugger somehow does not work at other tabs. – Antu mArk Nov 01 '16 at 17:43

0 Answers0