user133466
user133466

Reputation: 3415

How to create a subclass in Eclipse?

During lecture, my professor very quickly created a subclass in Eclipse.

The result has the "extend" keyword added to the subclass. I didn't see what buttons he clicked.

Does anyone know where should I click? (I think he right clicked on the current class in the package explorer, then New ==> class, then I'm lost on what to select).

Upvotes: 10

Views: 17114

Answers (6)

Gursevak
Gursevak

Reputation: 1

When you create a class, replace the name of superclass with the your superclass name, that will do the job.

Upvotes: 0

Sameet S
Sameet S

Reputation: 1

Rt click on class > Show in Package Explorer Ctrl-N > Class The selected class will be automatically populated as the super class and you can enter you class name to derive from that

Upvotes: 0

1234
1234

Reputation: 241

Type your super class name where highlighted

Please see the picture where to enter your existing super class

Upvotes: 1

Ward
Ward

Reputation: 2852

When you are viewing the class you want to subclass, open Type Hierarchy (press F4). Right click on the parent-to-be class, and in the menu go to new -> class ( or Ctrl-n , class ).

Upvotes: 16

Thinhbk
Thinhbk

Reputation: 2214

You can try to bind Keys for New (New Wizard: Class) command (for eg.: Ctrl + Alt + N) by open Window> Preferences > General > Keys.

And then, on new wizard window, change the Superclass box.

Hth.

Upvotes: 0

KV Prajapati
KV Prajapati

Reputation: 94645

Right click on project name on Package Explorer + Add New Class + Type package Name, Name (sub-class name), and Super class (or Click on Browse to choose super class).

Upvotes: 0

Related Questions