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.
![]()
The following quick fixes are available:
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 import' on problems in imports
Types
- Create new class or interface 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
- Add explicit import statement for ambiguous type references (two import-on-demands for the same type)
- If the type name is not matching with the compilation unit name either rename the type or rename the compilation unit
- Remove unused private types
Constructors
- Create new constructor for references to constructors that can not be resolved (this, super or new class creation)
- Reorder or remove arguments for constructor references that mismatch parameters
- Change method with constructor name to constructor (remove return type)
- Change visibility for constructors that are accessed but not visible
- Remove unused private constructor
- Create constructor when super call of the implicit default constructor is undefined, not visible or throws an exception
- If type contains unimplemented methods, change type modifier to 'abstract' or add the method to implement
Methods
- Create new method for references to methods that can not be resolved
- Rename to a similar method for references to methods that can not be resolved
- Reorder or remove arguments for method references that mismatch parameters
- Correct access (visibility, static) of referenced methods
- Remove unused private methods
- Correct return type for methods that have a missing return type or where the return type does not match the return statement
- Add return statement if missing
- For non-abstract methods with no body change to 'abstract' or add body
- For an abstract method in a non-abstract type remove abstract modifier of the method or make type abstract
- For an abstract/native method with body remove the abstract or native modifier or remove body
- Change method access to 'static' if method is invoked inside a constructor invocation (super, this)
- Change method access to default access to avoid emulated method access
Fields and variables
- Correct access (visibility, static) of referenced fields
- Create new fields, parameters or local variables for references to variables that can not be resolved
- Rename to a variable with similar name for references that can not be resolved
- Remove unused private fields
- Correct non-static access of static fields
- Add 'final' modifier to local variables accessed in outer types
- Change field access to default access to avoid emulated method access
- Change local variable type to fix a type mismatch
- Initialize a variable that has not been initialized
Exception Handling
- Remove unneeded catch block
- Handle uncaught exception by surrounding with try/catch or adding catch block to a surrounding try block
- Handle uncaught exception by adding a throw declaration to the parent method or by generalize an existing throw declaration
Others
- Add cast or change cast to fix type mismatches
- For non-NLS strings open the NLS wizard or mark as non-NLS
Quick Assist are proposals available even if there is no problem or warning: There is no light bulb shown so the user has to know the available assists.
Quick Assists
- Replace catch clause with throws declaration on the parent method
- Transform an expression statement to an assignment to a new local or new field
- Remove surrounding 'if', 'for', 'while', 'do' statement
- Remove surrounding try block with a single catch or finally block
- Remove surrounding anonymous class, block or parenthesis
- Local rename of a type, method or variable in a linked 'template' mode
- Surround selected lines with templates (''if', 'while'..)