aspose file tools*
The moose likes Java in General and the fly likes are variable variable-names possible? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "are variable variable-names possible?" Watch "are variable variable-names possible?" New topic
Author

are variable variable-names possible?

David Llewellyn
Ranch Hand

Joined: Feb 01, 2005
Posts: 45
I have a file which contains a list of URL's to class files. I'm reading this as a string into a URL and using URLClassLoader to load the URL's. However, there are many class URL's. and at the moment because I don't know any better I'm just hard-coding them in as class A,B,C etc.
is there a way I can use a variable to name another variable? This would make it much more straightforward and extensible.

Once again, cheers to all reading this
David Llewellyn
Ranch Hand

Joined: Feb 01, 2005
Posts: 45
actually, that was probably stupid hehe. I think it'd be better if I just created a class array and read into each slot in the array.
Ignore the last post
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Array is good. Glad you found a solution!

A List or Set is open-ended so you can do very similar stuff without having to know the number of entries before you start. If you need logical names for each URL you could look at Map. I load a lot of configuration stuff into maps as name-value-pairs.
[ March 04, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: are variable variable-names possible?