森森快跑

走得累,走得苦,那是因为在走上坡路。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Eclipse添加codeFormat模板(见附件)。

Windows--Preference--Java--Code Style--Format,   import附件中的模板。

                               --Java--Editor--Save Actions, 勾选Format source code,在编辑保存的时候就会自动format代码。相当方便。

 

格式如下:

/**
 * A sample source file for the code formatter preview
 */

package mypackage;

import java.util.LinkedList;

public class MyIntStack
{
    private final LinkedList fStack;
    
    public MyIntStack()
    {
        fStack = new LinkedList();
    }
    
    public int pop()
    {
        return ((Integer)fStack.removeFirst()).intValue();
    }
    
    public void push(int elem)
    {
        fStack.addFirst(new Integer(elem));
    }
    
    public boolean isEmpty()
    {
        return fStack.isEmpty();
    }
}

 

 

https://files.cnblogs.com/files/moleme/codeformat.rar