I am working with an array and need some help. I would like to create an array where the first field is a String type and the second field is an Integer type. For result:
Console out
a 1
b 2
c 3
I am working with an array and need some help. I would like to create an array where the first field is a String type and the second field is an Integer type. For result:
Console out
a 1
b 2
c 3
An array can only have a single type. You can create a new class like:
Class Foo{
String f1;
Integer f2;
}
Foo[] array=new Foo[10];
You might also be interested in using a map (it seems to me like you're trying to map strings to ids).
EDIT: You could also define your array of type Object but that's something i'd usually avoid.
Object [] field = new Object[6];
field[0] = "a";
field[1] = 1;
field[2] = "b";
field[3] = 2;
field[4] = "c";
field[5] = 3;
for (Object o: field)
System.out.print(o);
try using Vector instead of Array.