Quick fix

For certain problems underlined with a problem highlight line, the Java editor can offer corrections. This is shown by the light bulb shown in the editor marker bar.

A Java editor indicating a quick-fixable problem with a lightbulb in the editor marker bar

To see the correction proposals use the Quick Fix action

Note that the light bulb is only a hint. It is possible that even with the light bulb shown, it turns out that no corrections can be offered.

Provided corrections:

Problem

Correction Proposals

Unresolved method reference

  • Change to a method with a similar name
  • Create method



Unresolved variable name 

  • Change to a variable with a similar name
  • Create field
  • Create local variable
  • Create parameter



Unresolved type name 

  • Change to a type with a similar name
  • Create class
  • Create interface
  • Add import statement



Undefined constructor

  • Create constructor



Parameter mismatch

  • Change method name to matching method

Unhandled exception

  • Add try / catch statement
  • Add throws declaration to enclosing method



Type name does not match compilation unit name

  • Change type name
  • Change file name

Package declaration does not match file location

  • Change package declaration
  • Move file

Unused import

  • Remove import

Type mismatch

  • Add cast statement
  • Change declared type

Unterminated string

Non-Externalized string

  • Open Externalize String wizard

To enable / disable problem indication & the light bulb go to the Java Editor preference page > Annotations

Related concepts
Java editor
Java Development Tools (JDT)

Related tasks
Using quick fix

Related reference
Java editor preferences
Edit menu

Legal notices