在 Netbeans 中,如何键入不存在的方法并自动生成该方法?
在其他 IDE 中,我可以键入一个方法,就好像它存在一样,按下组合键即可生成该方法。
例如,我输入:
public List<String> getIds() {
int max = 4;
return generateRandomArray(max);
}
截至目前,方法 generateRandomArray
不存在。
然后,我按下组合键,它会生成:
private List<String> generateRandomArray(int max) {
return null;
}
如何在 Netbeans 中完成此操作,而无需手动键入方法?
In other IDEs, I can type a method as if it existed, hit a key combination and the method is generated.
For example, I type:
public List<String> getIds() {
int max = 4;
return generateRandomArray(max);
}
As of now, the method generateRandomArray
doesn't exist.
I then hit a key combination and it generates:
private List<String> generateRandomArray(int max) {
return null;
}
How do I accomplish this in Netbeans without having to type the method manually?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此外,文本编辑器窗口左侧应该有一个小图标(带有灯泡和红色 (!) ),位于包含
returngenerateRandomArray(max);
的行上,单击它并单击显示以下内容的选项:
Additionally, there should be a little icon (with a lightbulb and red (!) ) on the left side of the text editor window, at the line that contains
return generateRandomArray(max);
Click on it and click the option that reads:
按 alt+enter 键显示自动修复选项。然后,选择创建方法...(在大多数情况下这应该是唯一的选项)。
Press alt+enter to show the auto fix options. Then, select create method ... (which should be the only option in most cases).