Today I wanted to use the java code below and it did not work of course. I know that in order to process the idea below I should create a basic array which should include all my String variables but... I am wondering is there an option to change my code and process the code without the mentioned basic array ?
ArrayList<String> array = new ArrayList<String>();
String variable1 = "text1";
String variable2 = "text2";
String variable3 = "text3";
for ( int i = 1; i <= 3; i++ ){
array.add(i, variable + i ); // error
}
thank you in advance !