no offence, but what exactly is your problem?
also, why do you declare your argument as final? and why, if one of them is a final, do you give it the same name as your instance variable?
yes, been up late ... yes, had a lot to drink ... no, didn't completely understand your question. could you please elaborate a bit further?
stultuske
Industrious Poster
4,379 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24
It's hard to criticise the functionality of arbitrary code, but...
constructor was passing a null value, which in turn was setting a final variable. This variable will always hold a null value
OK, so ConceptC is like ConceptA except that it has a serial no, and its parent is always null. No problem with that as Java code.
ConceptA's constructor passes in a Concept instance to be set as ConceptA's parent. this did not seem correct as ConceptA extends Concept, so could pass in a ConceptB which is concrete class of Concept and set it as the parent of ConceptA, which is not good
Why "not good"? It's perfectly valid Java. Without attaching any meaning to these classes why shouldn't a ConceptA have a ConceptB as its parent?
JamesCherrill
... trying to help
8,521 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
why do you declare your argument as final?
That's a great question. There was a stage in the early days when people argued that all Java parameters should be final by default - to prevent people treating them as call-by-reference and being surprised when assigning a new value to a parameter didn't have the expected results. Nowdays we assume that people know that, and so the final keyword is very rarely used. IMHO if you assign an new value to a parameter then you're either confused, or you want to confuse someone else. I wish all params were final.
JamesCherrill
... trying to help
8,521 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30