【问题标题】:how to generate smart implements function in intellij idea, not only Ctrl+O如何在intellij idea中生成智能实现功能,不仅仅是Ctrl+O
【发布时间】:2016-09-10 03:52:02
【问题描述】:

当我这样 Ctrl+O 时:

public class Lists<E> implements List<E>{

    private final List<E> target;

    public Lists(List<E> target) {
        this.target = target;
    }

    @Override
    public int size() {
        return 0;
    }
}

其实我想要的是这个:

public class Lists<E> implements List<E>{

    private final List<E>t target;

    public Lists(List<E> target) {
        this.target = target;
    }

    @override
    public int size() {    
      return target.size(); 
    }
}

除了手动写,自动方式怎么样

谢谢

【问题讨论】:

    标签: intellij-idea autocomplete editor


    【解决方案1】:

    代码 |生成 |委托方法将生成具有将它们委托给成员之一的实现的方法(在本例中为“目标”字段)。

    更多详情请见https://www.jetbrains.com/help/idea/2016.2/generating-delegation-methods.html

    【讨论】:

    • 完美,非常感谢。我已经找到了一段时间
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-10
    • 1970-01-01
    相关资源
    最近更新 更多