Having access to a private variable from other classes in Java

Posted by Crystal on Stack Overflow See other posts from Stack Overflow or by Crystal
Published on 2010-06-10T04:30:43Z Indexed on 2010/06/10 4:32 UTC
Read the original article Hit count: 118

Filed under:
|

If I want to create a form that adds people to a List, how do I have access to that List from another class? Where would I define that List so other classes can access the members, the size, etc? For example, if I have Class Foo that has the GUI for my form, along with buttons to add and remove people to the List, it would make sense to me to declare the List as a private instance variable of Class Foo. But then if I have another class, Class Bar, how does it get the values that are currently in that List to update some other graphical components? Or is that the wrong place to declare the List in general? Thanks.

© Stack Overflow or respective owner

Related posts about java

Related posts about design