Java Reference
In-Depth Information
Declaration
command, your cursor moves to the initial declaration of the vari-
able, inside the
FixedRateCurrencyExchangeService
class:
public class FixedRateCurrencyExchangeService
implements CurrencyExchangeService {
private Currency defaultCurrency;
double rate;
...
}
If you execute the
Go To | Type declaration
command on a reference to
default-
Currency
, you're instead taken to the declaration of the symbol's type—that is, the
Currency
class.
public final class Currency {
public static final Currency USD = new Currency("USD");
public static final Currency CDN = new Currency("CDN");
...
}
To view a symbol's declaration without moving the caret, hold down the
Ctrl
key and hover your mouse over the symbol. The statement that de-
clared the symbol will appear in a tooltip window. Likewise, to view the
declaration of a symbol's type, hold down
Ctrl+Shift
and hover with the
mouse pointer.
Control
-clicking the symbol navigates you to that decla-
ration! This is one of the easiest and most often used ways of navigating
around the Java class tree.
TIP
A new Quick View feature in
IDEA
5.0 lets you see the code behind the symbol at
the caret. To activate it, place the caret at the symbol you're interested in and
select the
Code | Quick Definition Lookup
action (
Ctrl+Shift+I
). This option
displays the implementation in a pop-up window, and you can use its toolbar but-
tons to navigate to the source file if you wish. If multiple implementations are
available, you can switch between them using the drop-down at the top of the pre-
view window. This feature is a good alternative to
Go To | Declaration
(
Ctrl+B
)
when you want to quickly review the implementation and not necessarily load it
into the editor.