In the previous section, we saw how to create and customize templates for different file types. This can be very useful when creating new files.
NetBeans takes automatic code creation even further, however, with the ability to define both code templates and code snippets. Code templates allow a short piece of code to be entered within the main source code editor that is expanded into a larger template upon pressing the Tab key.
First, let's take a look at code templates. NetBeans provides over 100 code templates for the Java language and many more for JavaScript, HTML, and others. Some of the more common code templates are shown in the following table:
Code template |
Description |
---|---|
|
Expands to |
|
Expands into a |
|
Expands to a |
|
Expands to a |
|
Expands to |
|
Expands to |
... |