Java coding convention about static method

前端 未结 7 634
情深已故
情深已故 2021-02-05 16:24

It is a very simple question, but I think it is a little bit controversial.

When I code Java classes I use the following order.

class Foo {

    // stati         


        
7条回答
  •  日久生厌
    2021-02-05 17:10

    I don't know, but for what it's worth, I do what you do. Constructors on top, methods grouped by functionality (with no regard to staticness) below. Static methods tend to group.

    The exception is static factory methods that I intend for you to use instead of constructors -- if so, they are before constructors, and the ctors are private/protected.

提交回复
热议问题