adding arrayobject to arraylist

hi all,can u just tell me can i add an arrayobject to arraylist. if yes how and if no why?
[104 byte] By [vinnuvinoda] at [2007-11-27 5:28:28]
# 1
You mean you want to add the array's contents to the list?
quittea at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 2

ArrayList au = new ArrayList();

String[] name = new String[3];

name[0] ="test";

name[1] = "test1";

name[2] = "test2";

for(int i=0;i<3;i++) {

au.add(name[i]);

}

AnanSmritia at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 3

In case of an Object array:

list = java.util.Arrays.asList(array);

In case of a primitive or an Object array:

for (int i = 0, len = java.lang.reflect.Array.getLength(array);i < len;i++) {

list.add(java.lang.reflect.Array.get(array, i));

}

quittea at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 4
@Quitte: What is the advantage of going through reflection to get to the contents of an array?
Peetzorea at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 5
> @Quitte: What is the advantage of going through> reflection to get to the contents of an array?In pre-1.5, it does the boxing for you.
quittea at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 6

B4 J2SE 5.0

ArrayList alist = new ArrayList();

String str[] = {"hello","hi","Heh"};

alist.add(str);

String str1[] = (String[])alist.get(index);

from J2SE 5.0

ArrayList<String[]> alist = new ArrayList<String[]>();

String str[] = {"hello","hi","Heh"};

alist.add(str);

String str1[] = alist.get(index);

RahulSharnaa at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 7
I wish I had the same magic minds as you have, as the OP didn't even specify what he/she actually wants to add, and I couldn't find any reference to String[] so far in his/her question ...
quittea at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 8

>adding arrayobject to arraylist

wat does "arrayobject" indicate it could be a Object[],String[],Integer[] or .........

i've just taken an example of String[] out of those alternative.

I'm no magician and so do you...

Hope there are to hard issues...

U Have a gr8 day.. :)

REGARDS,

RaHuL

RahulSharnaa at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...
# 9
> wat does "arrayobject" indicate it could be a Object[],String[],Integer[] oror an int[] ;)
quittea at 2007-7-12 14:50:46 > top of Java-index,Java Essentials,Java Programming...