• Post Reply Bookmark Topic Watch Topic
  • New Topic

label arrays !!  RSS feed

 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to use a label array but it doesn't want to work here is some sample code
Label[] label1 = new Label[total];
for (int x = 0; x <= total; x++) {
label1[x].setText("test");
}
this throws me a NullPointerException ,
if anybody knows why please help

 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've created the array, but you haven't instantiated the objects inside it...



-Nate
 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nathan Pruett:
[B]You've created the array, but you haven't instantiated the objects inside it...



-Nate[/B]

thanks Nate, Thats so simple, I don't know where my mind is today , it's been hecktic
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!