> here is the problem
> I have an Object[] args[];
> I want use this array args to transfer the values.
> For example args[0] is a int; args[1] is a string.
> The problem is I can't change a int to string, I use this way
> int refer=1
> args[0]= (Object) refer;
You can't cast an int to an Object. Do this instead:
args[0] = new Integer(refer);

Signature
John Gordon "It's certainly uncontaminated by cheese."
gordon@panix.com
jartur - 31 Oct 2006 00:27 GMT
Uh-huh. The primitives are not objects, so they don't inherit from
Object thus you can't do that cast. Use primitive's wrappers.
Mike Schilling - 01 Nov 2006 04:12 GMT
>> here is the problem
>> I have an Object[] args[];
[quoted text clipped - 10 lines]
>
> args[0] = new Integer(refer);
Or, in 1.5, simply
args[0] = i; // will generate the same code as args[0] =
Integer.valueOf(refer);