List of Java live templates
Use live templates to insert common constructs into your code, such as loops, conditions, declarations, or print statements.
To expand a code snippet, type the corresponding template abbreviation and press ⇥. Keep pressing Tab to jump from one variable in the template to the next one. Press ShiftTab to move to the previous variable.
This table summarizes the live templates that you can use with your Java code.
Live template | Description / code snippet |
---|---|
| Surround with
|
| Add an
|
| Create an iteration loop:
|
| Create a singleton method
|
| Iterate over the elements of an
(The same as |
| Inserts a null check (an if null statement):
|
| Inserts a null check (an if not null statement):
|
| Checks object type with
|
| Iterates elements of an array:
|
| Iterates over the elements of a
|
| Iterates over the elements of
|
| Iterates over the elements of an
(The same as |
| Iterates over a
|
| Iterates over the elements of a
|
| Iterates over the tokens of a
|
| Performs a lazy initialization of a field:
|
| Fetches the last element of an array:
|
| Generates a main method declaration
(The same as |
| Assigns the lesser of the two values to a variable:
|
| Assigns the greater of the two values to a variable:
|
| Inserts |
| Inserts |
| Inserts |
| Inserts |
| Generates a main method declaration
(The same as |
| Iterates over the elements of an array in the reverse order:
|
| Surround with
See also: WL |
| Inserts |
| Inserts |
| Inserts |
| Inserts |
| Inserts |
| Prints the current class and method to
|
| Prints parameter names and values to
|
| Prints a value to |
| Inserts |
| Inserts |
| Stores the elements of a |
| Surround with
See also: RL |
Abbreviation | Description | Template text | Can be applied in |
---|---|---|---|
| Surround with Callable |
| 1 Java statement |
| Iterate Iterable or array |
| 1 Java statement |
| Surround with ReadWriteLock.readLock |
| 1 Java statement |
| String |
| 1 Java statement Declaration Expression |
| Surround with ReadWriteLock.writeLock |
| 1 Java statement |
| Add else-if branch |
| Else position |
| Create iteration loop |
| Java statement |
| Inserts singleton method getInstance |
| 1 Declaration |
| Inserts 'if null' statement |
| 1 Java statement |
| Inserts 'if not null' statement |
| 1 Java statement |
| Checks object type with instanceof and down-casts it |
| 1 Java statement |
| Iterate elements of array |
| 1 Java statement |
| Iterate elements of java.util.Collection |
| 1 Java statement |
| Iterate java.util.Enumeration |
| 1 Java statement |
| Iterate Iterable or array |
| 1 Java statement |
| Iterate java.util.Iterator |
| 1 Java statement |
| Iterate elements of java.util.List |
| 1 Java statement |
| Iterate keys and values of java.util.Map |
| Java statement |
| Iterate tokens from String |
| 1 Java statement |
| Performs lazy initialization |
| 1 Java statement |
| Fetches last element of an array |
| 1 Expression |
| main() method declaration |
| Declaration |
| Sets lesser value to a variable |
| 1 Java statement |
| Sets greater value to a variable |
| 1 Java statement |
| private static final |
| 1 Declaration |
| public static final |
| 1 Declaration |
| public static final int |
| 1 Declaration |
| public static final String |
| 1 Declaration |
| main() method declaration |
| Declaration |
| Iterate elements of array in reverse order |
| 1 Java statement |
| Prints a string to System.err |
| 1 Java statement |
| System.err::println |
| 1 Consumer function |
| Prints a formatted string to System.out |
| 1 Java statement |
| Prints a string to System.out |
| 1 Java statement |
| System.out::println |
| 1 Consumer function |
| Prints current class and method names to System.out |
| 1 Java statement |
| Prints method parameter names and values to System.out |
| 1 Java statement |
| Prints a value to System.out |
| 1 Java statement |
| throw new |
| 1 Java statement |
| Stores elements of java.util.Collection into array |
| 1 Expression |
Thanks for your feedback!