Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
259 views
in Technique[技术] by (71.8m points)

java - How to change auto-generated code when creating new class in Eclipse

Whenever I create a new Java file in Eclipse and check off the option to add public static void main(String args[]), this code is generated:

public class Test {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

    }

}

How do i:

  • Remove the @param args comment
  • Change the indentation so each { is on a line of its own
  • Remove the TODO auto generated comment
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The indention is a formatting issue while the comments is a template issue.

The templates are in Window -> Preferences -> Java -> Code Style -> Code Templates. Browse all of them and look for the things you would like to change.

The Formatter is a little bit more complicated. You find it under Window -> Preferences -> Java -> Code Style -> Formatter. There are tons of options there but I'll just answer your question.

  • Templates -> Comments -> Methods -> Edit and delete everything
  • Formatter -> Edit -> Braces Tab -> Change which situations you want
  • Templates -> Code -> Method Body -> Edit and delete everything

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...