Java Reference
In-Depth Information
The keyboard shortcuts works with variables as well.
NetBeans will indicate compilation errors in our code by underlining the erroneous
line with a squiggly red line as shown in the following screenshot. Placing the caret
over the offending code and hitting
Alt
+
Enter
will allow us to select from a series
of suggestions to fix our code:
Sometimes navigating through all the files in a project can be a bit cumbersome,
especially if we know the name of the file we want to open but we are not sure of
its location. Luckily, NetBeans provides the
Shift
+
Alt
+
O
keyboard shortcut that
allows us to quickly open any file in our project:
Additional useful keyboard shortcuts include
Shift
+
Alt
+
F
to quickly format
our code,
Ctrl
+
E
(
Cmd
+
E
on Mac OS) to erase the current line, much faster than
highlighting the line and hitting backspace. Sometimes we import a class into our
code and later decide not to use it. Frequently, the lines where the class is used are
deleted but we forget to delete the import line at the top of the source file. NetBeans
will generate a warning about the unused import; hitting
Ctrl
+
Shift
+
I
will delete
all unused imports in one fell swoop, plus it will attempt to add any missing imports.