File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Adding list element to Object array Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Adding list element to Object array" Watch "Adding list element to Object array" New topic
Author

Adding list element to Object array

Rodricks george
Ranch Hand

Joined: Sep 10, 2006
Posts: 97
Dear Sir,

I have a Object array and i want to add data inside, rite now i am adding two list inside
setToList (it is a araylist)
subFileList2 (it is a araylist)


Object[][] data = {
{setToList, subFileList2}

};

the problem is i want to add all element of List to the data array. for example

Object[][] data = {
{setToList.get(0), subFileList2.get(0)}

};

how can i achieve this.

-Thanks with regs,
Rodricks
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
I do not understand what exactly you are trying to accomplish.
Do you want "data" to be an array with 2 elements. The first one an array containing the elements of the first list and the second one containing the elements of the second list?

If so you need to do something like the following:


To convert the lists to an array, take a look at the toArray method of List.
Rodricks george
Ranch Hand

Joined: Sep 10, 2006
Posts: 97
Sir,

Yes...The first one an array containing the elements of the first list and the second one containing the elements of the second list

Object[][] data = {
{elements of the first list,elements of the second list}

};

thanks with regs,
Rodricks
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
Well, you can not do this in one go.
You will have to do something like:


As I said, to convert the list to an array, there is a toArray method in List.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding list element to Object array
 
Similar Threads
phonebook and array? help?
Webservice for beginners
access html form element value in servlet
Problem displaying data in table
problem in parsing an XML using SAX parser.