Quick Fix

The Java editor offers corrections to problems found while typing and
after compiling. To show that correction proposals are available for a
problem or warning, a 'light bulb' is visible on the editor's annotation
bar.

Left click on the light bulb or invoking Ctrl+1 (Edit > Quick
Fix) brings up the proposals for the problem at the cursor
position.
Each quick fix shows a preview when selected in the proposal
window.

Quick fixes are also shown directly in problem hovers (but there, no preview is available).

Usage hint: Quick fixes are not only useful to fix errors that accidentally occurred.
An other common usage pattern is to inentionally write "incorrect" code, for example by referring to
a local variable that is not declared yet. Then, the Create local variable Quick Fix can
generate the declaration in no time, and it can even infer the variable type.

Some selected quick fixes can also be assigned with direct shortcuts. You
can configure these shortcuts on the General > Keys preference
page (in the 'Source' category).

Some quick fixes offer to fix all problems of the same kind in the
current file at once. The information text in the proposal window contains
this information for all applicable proposals. To fix all problems of the
same kind, press Ctrl+Enter.

Here's a selection of available quick fixes:

Package Declaration

Add missing package declaration or correct package
declaration

Move compilation unit to package that corresponds to the
package declaration

Imports

Remove unused, unresolvable or non-visible import

Invoke 'Organize imports' on problems in imports

Types

Create new class, interface, enum, annotation or type
variable for references to types that can not be resolved

Change visibility for types that are accessed but not visible

Rename to a similar type for references to types that can not
be resolved

Add import statement for types that can not be resolved but
exist in the project