Matthew Tuman
Matthew Tuman

Reputation: 49

Creating a Java container class

I have been given an java assignment in school that requires me to create a StockQuote class. This would normally be easy, however the teacher has referred to it as a simple container class. I'm confused because everything that I read says container classes are things like java.util.Vector, java.util.Hashtable, and java.util.HashSet. I get the feeling he is using this term to mean something else, perhaps even just to mean a strightforward StockQuote class. I tried emailing him but he hasn't responded and I'd like to get a jump on the assignment. Here is the description from the assignment:

"A StockQuote class or interface. This a simple container class. Typically you would not use an interface for container classes, but you could. One rule for when to use an interface or not is to decided if there ever possibly could be more than one implementation of the class. If more than one implementation is possible, then using an interface definitely makes sense. In the case of simple container classes like this one, there probably will only be one implementation"

Any help or nudge in the right direction would be great. Thanks

Upvotes: 1

Views: 3105

Answers (1)

Dmytro Maslenko
Dmytro Maslenko

Reputation: 2297

In your case This a simple container class. == This a simple class..

In general your class may have some fields of other types, like String, Collections, etc. If so, you would say I have a container class because it contains/stores some data. Interfaces don't have fields, so they are not containers.

Upvotes: 1

Related Questions