Java Reference
In-Depth Information
to generate. You can find a full explanation of JavaDoc and the JavaDoc gener-
ation options with your JDK documentation.
3.6 Code completion
With a few quick keystrokes, IDEA 's code-completion and code-generation fea-
tures can stub out a method, create a new variable, or find the right method to
use. The objective of IDEA 's code-completion and code-generation features isn't
to attempt to write your code for you, as some rapid prototyping tools attempt to
do. Those types of code wizards and program generators rarely produce designs
that are as useful or maintainable as you'd hope. IDEA instead uses code genera-
tion as more of an assistance mechanism, eliminating the drudgery of common
coding tasks with predictable outcomes.
3.6.1
Using IDEA's code-completion features to do your work for you
IDEA has a built in code-completion feature that can save you a lot of typing by
suggesting appropriate code for you. As you'll see, IDEA can fill in method and
field names, find appropriate parameters, and so forth. Not only does it save you
some typing, but this feature also serves as a way of reminding you what API calls
are available.
Auto-importing required packages
When you reference a class that hasn't been imported into the current source
file, IDEA helps you by trying to locate the class in your Classpath and add it to
your list of imports. As shown in figure 3.10, the editor prompts you to accept
the import by displaying the fully qualified name of the class it plans to import.
Press Alt+Enter to import the class; or, if there are multiple matches on the class
name, select the class to import from the list presented. Whether the single class
Figure 3.10 Because IDEA knows about the entire class structure of your
project, it can suggest appropriate import statements when it notices classes
without them, like this OutputStream class.
 
 
 
 
 
 
 
Search WWH ::




Custom Search