Code templates are commonly used code fragments which can be inserted into the source
code. Eclipse provides a nice mechanism to do this. Just type 'main' in the
Java editor and press 'Ctrl + Space'. You can see the code completion window
as shown below. If you choose the second option you can insert a code template.
In the above example you will have the following code inserted.
public static void main(String[] args) {
}
This is a very simple template. There are more templates which can hold variables
editable in linked edit mode and can be a bit intelligent too. For example if you
use the 'catch' template it will intelligently add all the exceptions that
need to be caught. You can find the list of templates in Window > Preference
> Java > Editor > Templates. There are templates for looping through
arrays, collections etc.
The nice thing about templates is that you can edit the existing ones to suit your
needs and creates new templates. You can import and export templates too. This way
you can share the templates with your team.