how to stor an integer inside an object

Hii have intialized an Object[] a;i tried to enter an integer in to objecta[0] = 12;but i was not able to do so...how can we do this...
[177 byte] By [Stalwarts79a] at [2007-11-27 1:36:34]
# 1
As of 1.5, there is autoboxing. You can use an Integer. int value;Integer I = new Integer ( value) value = I.intValue();
BIJ001a at 2007-7-12 0:46:11 > top of Java-index,Java Essentials,New To Java...
# 2

> Hi

> i have intialized an Object[] a;

> i tried to enter an integer in to object

> a[0] = 12;

> but i was not able to do so...

> how can we do this...

First, you do not have an Object, you have an array of Objects.

Second, an int is a primitive an can not be directly referenced by an Object variable. You can wrap the primitive in its appropriate wrapper class and reference that object.

Object a;

a = new Integer(12);

Note: I was ignoring the autoboxing feature that BIJ001mentioned.

Message was edited by:

jbish

jbisha at 2007-7-12 0:46:11 > top of Java-index,Java Essentials,New To Java...