Re: Rules for constructors
From: Tony Morris (_at_dibblegoATbigpond.com@)
Date: 03/19/04
- Next message: Tony Morris: "Re: performance implication of calling interface methods"
- Previous message: Jimmy Zhang: "performance implication of calling interface methods"
- In reply to: Alex Hunsley: "Rules for constructors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 19 Mar 2004 22:08:42 GMT
> b) never call non-final methods from your constructor
> (or else they will be overridden causing chaos as I have experienced
> today)
To be more precise, never call an overrideable method from a constructor
using a 'this' reference.
An overrideable method is defined as any method that is non-private,
non-static, non-final and a member of a non final class.
This is the cause of your "problem".
A trivia question that takes advantage of this behaviour to cause
"trickery":
http://www.xdweb.net/~dibblego/java/trivia/answers.html#q4
-- Tony Morris (BInfTech, Cert 3 I.T., SCJP[1.4], SCJD) Software Engineer IBM Australia - Tivoli Security Software (2003 VTR1000F)
- Next message: Tony Morris: "Re: performance implication of calling interface methods"
- Previous message: Jimmy Zhang: "performance implication of calling interface methods"
- In reply to: Alex Hunsley: "Rules for constructors"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|