This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
You can't have variable names that are dynamically created like that, but you can use a collection. For example, you could create a Map<String, JLabel> and add your labels to that. Then you can refer to individual labels using the String you used as a key, or you can easily iterate across all of them.
Joined: Dec 11, 2012
Thanks for your reply.. It is a help..
Therefore there is no way to create you #(a given number from user) labels, right?
Oh, creating a given number isn't a problem - you just do it in a loop like your first example. But instead of assigning to a different variable every time, you put them in a collection that you've already created.