R
Rhino
Can someone answer a question that has been bothering me sporadically for a
while? I'm afraid I'm weak in OO theory and don't know where to look this
up.
What is the difference between:
TreeSet set = new TreeSet();
and
Set set = new TreeSet();
I'm not particularly concerned with Sets or TreeSets, this is just an
example of an idiom I see occasionally in examples. The same issue occurs in
the examples:
GregorianCalendar cal = new GregorianCalendar();
Calendar cal = new GregorianCalendar();
The first one of each pair makes sense to me: I'm making an instance of a
specific class via a "new". But the second of each pair mystifies me: what
is the difference between these two and what are the implications of each
approach? In other words, what are the consequences of specifying a subclass
of the original class after the new keyword versus specifying the original
class name after the new keyword?
while? I'm afraid I'm weak in OO theory and don't know where to look this
up.
What is the difference between:
TreeSet set = new TreeSet();
and
Set set = new TreeSet();
I'm not particularly concerned with Sets or TreeSets, this is just an
example of an idiom I see occasionally in examples. The same issue occurs in
the examples:
GregorianCalendar cal = new GregorianCalendar();
Calendar cal = new GregorianCalendar();
The first one of each pair makes sense to me: I'm making an instance of a
specific class via a "new". But the second of each pair mystifies me: what
is the difference between these two and what are the implications of each
approach? In other words, what are the consequences of specifying a subclass
of the original class after the new keyword versus specifying the original
class name after the new keyword?