Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating Stings Dynamically  RSS feed

 
Ranch Hand
Posts: 1826
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to loop through an array and create String objects. How can I get this to work?

>
 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's impossible.

I found the same question a while ago in other forum.
But.. i suggest you store all it on a ArrayList and to access you can use it using the get(int index) from the List interface.
 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It really depends on what you're trying to achieve. If you just want some sort of formatting on the original objects, give them a method to return an appropriately formatted String.

 
Sheriff
Posts: 21289
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need the contents of each "variable" as well, try a map:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!