I am looping to write data to an array of Strings. But what I want is that I create another loop where I will loop through the data of values as much as amount, but I would like to have some guidance on how to do so.
String[] s = new String[20];
String[] values = { "A", "B", "C", "D" };
final int amount = 2;
for (int i = 0; i < s.length; i++) {
s[i] = String.format("%s%04d", values[0], i); //TODO create another loop?
}
System.out.println(Arrays.toString(s));
The preferred output should be:
A0000, A0001, B0002, B0003, C0004, ...
The actual output is:
A0000, A0001, A0002, A0003, A0004, ...
Icame into outputIA20000? Why you usedvalues[0]inString.format? What will be the purpose of"B", "C", "D"invalues?System.out.println(Arrays.toString(s));would get you the desired output to some degree, but the code you've shared doesn't show what you put in theclassesvariable that you're using as output provider...