Alex Rivera | Logout

Multiple type array

Asked 2012-04-04T08:45:55.560
9

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
Edit
Report

2 Answers

1
Object[] randArray = new Object [3]; 
randArray[0] = new Integer(5);
randArray[1] = "Five";
randArray[2] = new Double(5.0);

for(Object obj : randArray) {
    System.out.println(obj.toString());
}

Is this what you're looking for?

answered 2012-04-04T08:49:40.630
-4

try using Vector instead of Array.

answered 2012-04-04T08:49:27.280

Your Answer