Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create n number of variables of different name at runtime

 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Mohamed Sanaulla
Saloon Keeper
Posts: 3159
33
Google App Engine Java Ruby
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Pramod P Deore
Ranch Hand
Posts: 632
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mohamed. I got it. Thanks once again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic