如何在 Eclipse 中创建子类?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7508498/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a subclass in Eclipse?
提问by user133466
During lecture, my professor very quickly created a subclass in Eclipse.
在讲座中,我的教授很快在 Eclipse 中创建了一个子类。
The result has the "extend" keyword added to the subclass. I didn't see what buttons he clicked.
结果在子类中添加了“extend”关键字。我没有看到他点击了什么按钮。
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).
有谁知道我应该点击哪里?(我认为他右键单击了包浏览器中的当前类,然后是New==> class,然后我不知道要选择什么)。
回答by Ward
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 ).
当您查看要子类化的类时,打开类型层次结构(按 F4)。右键单击父类,然后在菜单中转到 new -> class (或 Ctrl-n , class )。
回答by adatapost
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).
在项目名称上右键单击Package Explorer
+ 添加New
类 + 类型package
名称、Name
(子类名称)和Super class
(或单击浏览以选择超类)。
回答by Thinhbk
You can try to bind Keys for New (New Wizard: Class) command (for eg.: Ctrl + Alt + N) by open Window> Preferences > General > Keys.
您可以尝试通过打开“窗口”>“首选项”>“常规”>“键”来尝试为新建(新向导:类)命令(例如:Ctrl + Alt + N)绑定键。
And then, on new wizard window, change the Superclass box.
然后,在新的向导窗口中,更改超类框。
Hth.
嗯。