This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Passing String for an object name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Passing String for an object name" Watch "Passing String for an object name" New topic
Author

Passing String for an object name

Joseph Russell
Ranch Hand

Joined: Jan 08, 2001
Posts: 290
Is it possible to do this:

Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

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


SCJP
Visit my download page
Joseph Russell
Ranch Hand

Joined: Jan 08, 2001
Posts: 290
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Passing String for an object name
 
Similar Threads
How can I create an object based on input
Instantiate a generic parameter type
still a GC question ,help
navigator.plugins array
difference b/n Class.newInstance and new