How do I generate constructors?
Author: Deron Eriksson
Description: This tutorial describes how to generate constructors in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)
(Continued from page 1)
Next, I'll create another constructor. I right-click the Editor and select Source → Generate Constructor using Fields.
This time, I specify to create a constructor to initialize just aStringVariable and aBooleanVariable, in that order. I specify to create a protected constructor and click OK.
In our Test class editor, we can see that a protected Test constructor was created with a String parameter and a boolean parameter to initialize the String and boolean member variables in our Test class.
As a keyboard shortcut, you can hit Alt-Shift-S followed by O to bring up the 'Generate Constructor using Fields' window.