LinkedList declared as an abstract superclass
I'm new to JAVA and even newer to Java Forums. I hope you don't find it annoying that my first post is a "need help" one.
Having studied the basics of the language for the last 2 months, I've been trying to solve some typical programming problems. Currently, I'm stuck in the following situation:
There's an abstract superclass with an X attribute (type double) and an abstract method, whose definition is done differently in 3 subsequent subclasses. So far, so good.
The idea is to have some structure (LinkedList ?) that can keep trace of several objects (unlimited number), whose type can be any of the 3 subclasses referred above. I would also like the structure to be sorted accordingly to the X attribute. Then, my idea is to run that structure and execute the method in each of its objects.
Since I want to have objects organised accordingly to a parameter, I think that LinkedList is the best structure to use. The problem is that I don't know if it is possible to declare such List as being of the abstract superclass type, and then add objects to it that are subclass types. I also don't have a clue of a way to sort it accordingly to a specified attribute...
I'm really not sure of anything...
Which is the best way to do such thing? I appreciate any kind of guidance.
Thanks in advance.
PS: sorry if my English is not natural. it is not my mother language.