Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Java in General and the fly likes Convert ArrayList to List Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Convert ArrayList to List" Watch "Convert ArrayList to List" New topic
Author

Convert ArrayList to List

Anwarul Kabir
Greenhorn

Joined: Dec 17, 2008
Posts: 6
Hi

I have this arrayList and I need to return this as List<TransactionSummary>.

Is there any way I could load the data from arrayList to List<TransactionSummary>

my ArrayList which is called list is doing this

list.add(parseResultSetRow(rs));

The method parseResultSetRow() is returning TransactionSummary type.

Hope this makes sense.

BTW you probably can tell i am very new at this... so please hlp.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18523
    
  40

An ArrayList IS-A List. There is no need to convert it. Just return the ArrayList as the List.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37991
    
  22
And welcome to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert ArrayList to List
 
Similar Threads
Usage of wildcard?
how to add an array to an ArrayList
Question about Generics in Arrays
How to retain type of objects in arraylist ?
Generics