In Netbeans, how do I type a non-existent method and have the method get generated automatically?
In开发者_JS百科 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?
Press alt+enter to show the auto fix options. Then, select create method ... (which should be the only option in most cases).
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.
精彩评论