Eclipse adds the Codeformat template (see Attachment).
Windows--preference--java--code Style--format, import the template in the attachment.
--java--editor--save Actions, tick format source code, and the format code will be automatically edited when it is saved. Very convenient.
The format is as follows:
/*** A Sample source file for the Code formatter preview*/ PackageMyPackage;Importjava.util.LinkedList; Public classmyintstack{Private FinalLinkedList Fstack; PublicMyintstack () {Fstack=NewLinkedList (); } Public intpop () {return((Integer) Fstack.removefirst ()). Intvalue (); } Public voidPushintelem) {Fstack.addfirst (NewInteger (elem)); } Public BooleanIsEmpty () {returnFstack.isempty (); }}
Http://files.cnblogs.com/files/moleme/codeformat.rar
Java Learning (vii): Codeformat configuration, setting automatic format when save. The format template is attached.