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 Araylist of objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Araylist of objects" Watch "Araylist of objects" New topic

Araylist of objects


Joined: Nov 17, 2001
Posts: 2
I am implementing an ArrayList of objects which are of type StudentInfo for this course registration system I am making. The class StudentInfo contains many variables. I want to do a few things to the ArrayList. The first is search the ArrayList's Objects for a particular field like SocialSecurityNumber. Secondly, I want to be able to access the variables within an object as well as send a copy of the object over a socket connection. I have seen implementations of casting the list into an array which has type Object, but I can not access any of the methods in StudentInfo objects through that. I am really confused, if anyone could help I would appreciate it alot.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You will have to cast the arraylist element you retrieve to it's appropriate type, in this case, studentInfo, then use that reference to access the SSN vsriable, or access the method that will get you the SSN variable.

SCJP for the Java� 2 Platform

So much trouble in the world -- Bob Marley
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059

Please do not cross-post. Many people read more than one forum, as you obviously did. I am closing this thread. please refer to for any further response/questions regarding this subject.

Also, please read and re-register. We would like you to continue to post here at JavaRanch.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: Araylist of objects
It's not a secret anymore!