在 Netbeans 中,如何键入不存在的方法并自动生成该方法?

发布于 2024-08-14 16:34:15 字数 404 浏览 3 评论 0原文

在其他 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦在深巷 2024-08-21 16:34:16

此外,文本编辑器窗口左侧应该有一个小图标(带有灯泡和红色 (!) ),位于包含 returngenerateRandomArray(max); 的行上,

单击它并单击显示以下内容的选项:

创建方法generateRandomArray(int)
在 MyPackage.MyClass 中。

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:

Create method generateRandomArray(int)
in MyPackage.MyClass.

叹梦 2024-08-21 16:34:15

按 alt+enter 键显示自动修复选项。然后,选择创建方法...(在大多数情况下这应该是唯一的选项)。

Press alt+enter to show the auto fix options. Then, select create method ... (which should be the only option in most cases).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文