Java Reference
In-Depth Information
Code Templates
Code templates are abbreviations for frequently used code snippets. To use a
code template, we simply type it into the editor and hit the Tab key to expand the
abbreviations into the full code snippet it represents.
For example, typing sout and pressing the Tab key will expand into System.out.
println(""); , with the caret placed between the two double quotes.
Some of the most useful code templates are listed in the table below, please note that
code templates are case sensitive.
Abbreviation Example Expanded Text
Description
Psf
public static final
Useful when declaring public
static final variables.
forc
for (Iterator it = list.
iterator();
it.hasNext();) {
Object object = it.next();
}
Use a standard for loop to
iterate through a collection.
fore
for (Object object : list) {
Use the enhanced for loop to
iterate through a collection.
}
ifelse
if (boolVar) {
Generate an if-else
conditional.
} else {
}
psvm
public static void main(String[]
args) {
Generate a main method for
our class.
}
soutv
System.out.println("boolVar = " +
Generate a System.out.
println() statement
displaying the value of a
variable.
boolVar);
trycatch
try {
Generate a try/catch block.
} catch (Exception exception) {
}
whileit
while (iterator.hasNext()) {
Object object = iterator.
next();
}
Generate a while loop to
iterate through an Iterator.
 
Search WWH ::




Custom Search