Java Reference
In-Depth Information
several others, too. Now, look at what
Eclipse shows you when you enter the
code exactly as it's typed. If you try
to run the program now, Eclipse will
warn you that there are errors and ask
if you would still like to proceed. See
Figure 6-1.
You can see that Eclipse points out syn-
tax errors as you type, so you can more
easily find them and fix them immedi-
ately. Errors are indicated in the code
itself by a red underline, and also noted
to the left of the line number as a red
X. If you hover your mouse over the red
X, you will see a pop-up note indicat-
ing what Eclipse thinks the problem is, as shown in Figure 6-2.
figure 6-1  
figure 6-2  
The note age cannot be resolved to a variable indicates that a variable called age has not
been declared yet. Therefore, you cannot assign it a value. If you click on the red X, a new popup
window appears with possible solutions for the error, if Eclipse has one or more solutions to pro-
pose. See Figure 6-3.
By double‐clicking on the first solution, Create local variable 'age' , the code is automatically
edited to include the variable declaration. You can see that it becomes an int variable, because Eclipse
assumes a value of 30 belongs to an int data type. Also, the red X now shows as a faint white X,
so you can see that the error was resolved. See Figure 6-4. When you save the file, this white X will
Search WWH ::




Custom Search