• Post Reply Bookmark Topic Watch Topic
  • New Topic

NullPointerException with setting up an array of Rectangles  RSS feed

 
Jay Orsaw
Ranch Hand
Posts: 356
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I am having an issue with this array of Rectangles... p.numFaces is 115, and even if I put a number like 1000, I will still get this error... I have done this in another class which is exactly the same, except these are floats(It didn't work with the normal Rectangle class either...) Am I missing something simple? I've tried multiple variations of settling it up, but nothing worked...



 
Amit Bhargava
Greenhorn
Posts: 20
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've created the array 'face', but are you initializing the members of that array? setRect won't work if face[j] is null
 
Jay Orsaw
Ranch Hand
Posts: 356
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amit Bhargava wrote:You've created the array 'face', but are you initializing the members of that array? setRect won't work if face[j] is null


face[j] = new Rectangle2D.Float(p.faceX[j], (p.faceY[j]+OFFSET), p.faceW[j], p.faceH[j]); works(as in no errors), yeah I was really tired, thanks for the help!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!