0

I'm trying to initialize 18 label with some string my labels are of the form

label1 , label2 , label3 , ..... , label18

is there a way i use a loop with something like

label + i 

to get each one of my labels and perform some operation on it ?

3
  • Yes, use an array or an ArrayList. That's what they're for. i.e., SomeType[] labels = new SomeType[18]; Commented Oct 29, 2014 at 22:04
  • @Ahmed Fahmy, it's not possible to do whatever you are thinking to do in Java. Instead, use string array, for example, String[ ] labelArray = new String[ ]; for(int i = 0; i < 18 ; i++) { labelArray[ i ] = "test label"; }. And you can again use same for loop to extract the value. Hope it's helps you. Commented Oct 29, 2014 at 22:57
  • Thank you , i didn't manage to solve it , i manually assigned all created variables to array indexes and used it to reference the original variables Commented Oct 30, 2014 at 23:17

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.