Reputation: 7331
say I had an abstract java class in eclipse. Now I want to create some subclasses of that abstract class. Is there a way to create them automatically where I just enter the name of the class and eclipse creates the necessary methods?
I thought that I would find it in the "Refactor" option but I didn't. Can someone help me?
Upvotes: 1
Views: 11972
Reputation: 11890
Yes, create a new class using Right Click (on the package where you want to create the class) > New > Class, and in the SuperClass field, you can select your abstract
class. Be sure that the checkbox Which method stubs would you like to > Inherited abstract methods is checked.
If you have already created your class, you can make it extend you abstract
class by hand, and use Right Click (on the source code) > Source > Override/Implement Methods... and choose which methods you want to implement (if they are not already implemented).
An other way to do it, is to extend your abstract
class by hand, and use the Quick Fix provided by Eclipse to Add unimplemented methods. You can call the Quick Fix tooltip by highlighting the error and using Ctrl+1, or by clicking on the error icon on the left of the code.
Upvotes: 5
Reputation: 41123
Just create a class extending the abstract class, by default eclipse will add all unimplemented methods
Upvotes: 0
Reputation: 32949
Use the New Class
as normal but then specify your abstract class as the Superclass
. Then check Which methods stubs would you like to create
-> inherited abstract methods
Upvotes: 0