Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve elements from a Arraylist in another class..

 
Leeee Ming
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to retrieve elements from a Arraylist in another class..???

I have 2 classes SMS class and a Message class...

my SMS class is used to store text messages in an Arraylist...

While my Message class is used to retrieve messages from the Arraylist found in my SMS class..

How do i retrieve from an arraylist found in another class??

Thanks
 
C. Nimo
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ola.
the answer depends on how you defined the ArrayList in your SMS class.
if the Message class may access it directly - (i.e. - it is public, or you have your classes in the same package and declared it with package access) -you could just use it straight away. something like:

(This is inside the Message class)


however - this is not a good solution in terms of software engineering.
what you probably want to do is have methods in your SMS class for retrieving / deleting messages -

was that any help?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic