加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java checkstyle – 错误顺序的构造函数定义

发布时间:2020-12-15 00:24:41 所属栏目:Java 来源:网络整理
导读:我有一个看起来像这样的课程: public final class OrderedSetListT extends Comparable? super T implements OrderedSetT { // Constructor definition in wrong order checkstyle error next line public OrderedSetList() { // Initializations }} 任何人
我有一个看起来像这样的课程:
public final class OrderedSetList<T extends Comparable<? super T>> implements OrderedSet<T> {

    // Constructor definition in wrong order checkstyle error next line
    public OrderedSetList() {      
        // Initializations
    }
}

任何人都可以告诉我为什么在我的构造函数中有一个“错误顺序的构造函数定义”错误?

这是一项任务,我们有自己的checkstyle配置,不允许任何checkstyle错误.

我感谢你的帮助.

解决方法

checkstyle rule确保您遵循声明顺序的代码约定:

The parts of a class or interface declaration should appear in the following order:
Class (static) variables. First the public class variables,then the protected,then package level (no access modifier),and then the private.
Instance variables. First the public class variables,and then the private.
Constructors
Methods

它希望构造函数成为第一个方法.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读