Quick Fixes
Whenever you make a syntax error in your program, Eclipse's background compiler detects it immediately and draws an error indicator (affectionately known as the red squiggle) under the offending code. In addition to simply detecting the problem, Eclipse can usually offer an automatic program correction, called a quick fix.
For example, try misspelling the System.out method println as printline. Press Ctrl+1 (Edit → Quick Fix) to see several possible fixes. One of them will be Change to println(..). Press the down arrow to see a preview of each proposed change; press Enter to accept the one you want.
The Quick Fix command can also make suggestions for small source transformations on lines that don't have errors. For example, if you have code like this:
if (!(hail || thunder))and you select the text (!(hail || thunder) and press Ctrl+1, Eclipse will suggest some possible transformations, such as "Push negation down." Choosing that particular option would change the code to:
if (!hail && !thunder)Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access