• Post Reply Bookmark Topic Watch Topic
  • New Topic

variable that holds a object  RSS feed

 
brandon sexton
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I: create a variable which will hold a new ScoreBoard object called game - do not create the object yet, just the variable?

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
brandon sexton
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did that and got a error when I initialized the object:
error: game is already defined.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66304
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, yeah. If you try to define it a second time, you'll get that error. Why is that a surprise?

If you want to create an instance and assign it to the already-created variable, don't declare it a second time:



 
brandon sexton
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!