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

后端 未结 5 1841
渐次进展
渐次进展 2020-12-04 22:03

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:

pub         


        
相关标签:
5条回答
  • 2020-12-04 22:33

    Eclipse has a lot of configuration options. Take a look in the Windows | Preferences dialog (or the Eclipse Preferences pan on OSX).

    If you dig deep enough - you'll find the options under Java | Code Style.

    0 讨论(0)
  • 2020-12-04 22:35

    To configure it go to the : window->preferences->java->code style->code templates

    0 讨论(0)
  • 2020-12-04 22:37

    Also make sure you check "Use code formatter" in Java > Editor > Templates

    0 讨论(0)
  • 2020-12-04 22:43

    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
    0 讨论(0)
  • 2020-12-04 22:51
    1. In Eclipse Go to Window->Preferences
    2. In Left Panel, Select Java->Code Style->Code Template
    3. Under "Configure generated code and comments", Expand Comments-> select Methods,Click Edit Remove or replace the pattern ( * @param args),Click OK
    4. Under "Configure generated code and comments", Expand Code-> select Method Body,Click Edit Remove or replace the pattern ( // TODO Auto-generated...),Click OK
    5. Click OK !
    0 讨论(0)
提交回复
热议问题