When creating a new class in Eclipse via File > New > Class, please ensure that you had ticked the checkbox ‘Generate comments‘ if you wish there are useful comments included in the new class.
The auto-generated comment is as following:
/**
*
*/
package com.chapter7.arrays;
/**
* @author mychin
*
*/
public class Exercise713 {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
I would prefer to have useful information included in the file so that I can know the date and time that I had created the file. In order to customise the auto-generated comment, here are the following steps:
1. Under Eclipse > Preferences
2. Expand the ‘Java‘ section on the left sidebar
3. Choose Code Templates via Java > Code Style
4. Expand the ‘Comments‘ section and choose ‘Types‘.
5. By default, the pattern is as following:
/**
* @author ${user}
* ${tags}
*/
In order to customise the comment and add the date and time, you need to customise the pattern as following:
/**
* @author ${user}
* @date ${date}
* @time ${time}
* ${tags}
*/
After the customisation, when you create a new file, it will look like this:
/**
*
*/
package com.chapter7.arrays;
/**
* @author mychin
* @date Nov 30, 2012
* @time 11:06:05 PM
*/
public class trying {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
















