• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Araylist of objects

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


------------------
Bosun
SCJP for the Java� 2 Platform
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ichabod,

Please do not cross-post. Many people read more than one forum, as you obviously did. I am closing this thread. please refer to http://www.javaranch.com/ubb/Forum1/HTML/002278.html for any further response/questions regarding this subject.

Also, please read http://www.javaranch.com/name.jsp and re-register. We would like you to continue to post here at JavaRanch.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic