简体   繁体   English

关于Eclipse中的课程模板,如何为课程创建模板?

[英]About class template in eclipse, how to create a template for class?

I want to create many similar class that is: 我想创建许多类似的类:

inheritance a base class, 继承基类,
have some common annotations. 有一些常见的注释。

In eclipse, I can only create a class has a base class, so I wander if there a "template" mechanism in eclipse that can achieve this. 在eclipse中,我只能创建一个具有基类的类,因此我在eclipse中是否存在可以实现此目的的“模板”机制而四处徘徊。

You can create various Java code templates in Eclipse via the 您可以通过Eclipse在Eclipse中创建各种Java代码模板

Window->Preferences->Java -> Editor -> Templates 窗口->首选项-> Java->编辑器->模板

class SampleClass<T> {
  private T sampleData;

  public SampleClass() {
  }

  public void set(T sampleData_) {
    sampleData = sampleData_;
  }
}

You probably apply the template like above. 您可能像上面一样应用模板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM