Chodzi ci o coś takiego:
String[] input = { "DAMAGE:7", "PROTECTION:2"};
String[] names = new String[input.length];
int[] values = new int[input.length];
for (int i = 0;i < input.length; i++) {
String[] split = input[i].split(":");
names[i] = split[0];
values[i] = Integer.valueOf(split[1]);
}
Gdy dopiszesz wyświetlanie:
for (int i = 0;i < input.length; i++) {
System.out.print("Name: ");
System.out.print(names[i]);
System.out.print(", value: ");
System.out.print(values[i]);
System.out.println();
}
To wynik będzie:
Name: DAMAGE, value: 7
Name: PROTECTION, value: 2
To chciałeś osiągnąć?