File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Return object values from ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Return object values from ArrayList" Watch "Return object values from ArrayList" New topic

Return object values from ArrayList

Lori Gardner-Wilson

Joined: Jun 03, 2009
Posts: 11

Hello -

I am just starting to learn Java and am in a bit over my head.

I have an ArrayList (clientList) with Client objects.

How to I return the clientList with the attributes of the Client objects?

I've included code for the class that handles the serialization/deserialization and the testClass I'm using to return the data.

Test Code

Code for serializing/deserializing - not done with the lookupClient code yet....not sure how to do this exactly

Thanks a ton.
John de Michele

Joined: Mar 09, 2009
Posts: 600

Welcome to JavaRanch!

It looks like you're using JUnit, and IIRC, JUnit tests are required to have a void return value. You may want to just use a normal Java class, so your methods can return ArrayList<Client> values.

Lori Gardner-Wilson

Joined: Jun 03, 2009
Posts: 11
Thanks I will try that.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36478
And if you are using Eclipse, get rid of those default "return null;"s
I agree. Here's the link:
subject: Return object values from ArrayList
Similar Threads
paritial serialization
Failed to obtain specified collection
ObjectStream client-server object sharing problem.
Very New (obviously) - Program terminates
Deserialize and display an object's attributes in UI