Friday 15 July 2011

java - Change constructor template in Eclipse so it calls setter(s) -


For a sample rectangle class, the creator automatically generated in Eclipse using code templates,

  public rectangle (double width, double side) {this.width = width; This.height = Height; }  

However, the setter is designed to handle, I should like it (without changing myself)

  the public rectangle (double Width, double side) {set width (width); SetHeight (height); }  

Appreciate any help!

An anti-pattern calling agent is an ovevrridable method and this is why eclipse does not support it is. Due to being a superclass constructor, the subclass moves in front of the constructor, so before executing the sub-class constructor, the overwritten method will be applied in subclass. If the overriding method relies on an initialization performed by a sub-class constructor, then the method does not behave as expected.


No comments:

Post a Comment