• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing String for an object name

 
Joseph Russell
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to do this:

 
Randall Twede
Ranch Hand
Posts: 4535
6
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im not certain. The best thing to do when you have questions like this is to just try it. Try replacing
// Other goodies....
with something like this:
foo.add(new java.awt.Button("bar");
and see if you get a compile error.
I might even try it myself
 
Joseph Russell
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was getting an error. I think my problem was that I was attempting to name my object from an instance variable inside the method.
Joe
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!