How can I sort class members by name in NetBeans, or another Java IDE?

前端 未结 8 1662
小蘑菇
小蘑菇 2021-02-13 06:01

I want to sort members by name in the source code. Is there any easy way to do it?

I\'m using NetBeans, but if there is another editor that can do that, just tell me th

8条回答
  •  南方客
    南方客 (楼主)
    2021-02-13 06:51

    Here is the easy way to do it in NetBeans:

    1. Go to the Tools tab and chose Options. The option Window should appear.
    2. Click on Editor and chose the Formatting Tab.
    3. Select Ordering for Category. Ordering is the last element from the drop down Category list.
    4. Uncheck the Sort Members By Visibility field. At this point only the "Sort Members in Groups Alphabetically" should be checked.
    5. Click Apply and exit the Option window. Now you globally set to sort members alphabetically.
    6. Open or Select the source file you want to sort the members.
    7. Click the Source Tab (upper right corner) and chose Organize Members.

    And that is it. Your source file should have the members sorted alphabetically.

提交回复
热议问题