aspose file tools*
The moose likes Java in General and the fly likes create n number of variables of different name at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "create n number of variables of different name at runtime" Watch "create n number of variables of different name at runtime" New topic
Author

create n number of variables of different name at runtime

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Hi ranchers I want to create n number of objects ( say String ) of different names then How to do this?

if suppose I use for loop



if suppose n value is 10 here above code creates n String objects. But I want all these String objects name unique. How to do that?

Thanks in advance>


Life is easy because we write the source code.....
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3071
    
  33

How about using an array? or a Map? So each entry would be your 1 variable. With Map you can give those entries some name as well


Mohamed Sanaulla | My Blog
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Thanks Mohamed. I got it. Thanks once again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: create n number of variables of different name at runtime