I'm trying to think of the most intelligent way to do the following: I want to write a class that contains a collection Cache of objects of type Member. The Member class is nested within the Cache class. Different classes should be able to call the Cache, but I want to maintain a single static set of the elements going into the Cache. A few questions arise in this case:
1. How do I declare the set to be used within the Cache? (Right now, when declaring global field for my class, I have
private static LinkedList<CacheMember> mru_list = null; as a global field for the Cache class, but does this mean that every time the Cache class is called, my static list is getting reset to null? How can I avoid this? (I tried simply writing
private static LinkedList<CacheMember> mru_list; at the declaration of my global field, but the problem is that I heard it was bad practice to leave a field uninitialized, so I wanted to avoid doing this...))
2. Is the Cache class begging to implement the Collection interface? (This isnít a school project, Iím simply trying to become a better programmer, so Iíd like to follow good logical form.)
Any feedback would be greatly appreciated!