aspose file tools*
The moose likes Java in General and the fly likes Array and mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Array and mapping" Watch "Array and mapping" New topic
Author

Array and mapping

Joseph Smithern
Ranch Hand

Joined: Feb 11, 2006
Posts: 89
I have something that works with data mapping but was wondering if I can add an array in the add method part:

Change this -> myMap.add(firstname + "," + lastname + "," + address);
To something like this? -> myMap.add(array instead here...);


Here is what I have now:



output:

Please advise.
[ July 06, 2008: Message edited by: Joseph Smithern ]
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 686
Have you read the API doc for the add() method?
public boolean add(E e)

It looks like you can add any object.
Have you tried coding and compiling and executing a simple example?
Write a 10 line program and see what happens.
Santhosh Kumar
Ranch Hand

Joined: Nov 07, 2000
Posts: 242
List.add() method takes Object as input to add to the list so it means you can sure add an array instead of a String but beware that when you call get(0), you will get the same array back.

If this is not what you expect (to add array instead of elements in it), you can subclass the arraylist and override the add method to do just that.
[ July 06, 2008: Message edited by: Santhosh Kumar ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array and mapping