简体   繁体   English

<>在类名中意味着什么?

[英]What does <> mean in a classname?

My question is what does this: 我的问题是这是什么:
<RecentActivity, RecentActivityController>

mean in this code: 意思是在这段代码中:
public class RecentActivity extends AbstractActionActivity<RecentActivity, RecentActivityController>

Actually I want know the concept of the < and > operators. 其实我想知道<和>运算符的概念。 Clould someone give references to learn about them? 有人提供参考资料来了解它们吗?

This is known as generics and here AbstractActionActivity is a generic class which accepts two parameters. 这被称为泛型,这里AbstractActionActivity是一个接受两个参数的泛型类。 For example, from the oracle tutorials: 例如,从oracle教程:

public class Box<T> {
    // T stands for "Type"
    private T t;

    public void set(T t) { this.t = t; }
    public T get() { return t; }
}

As you can see, all occurrences of Object are replaced by T. A type variable can be any non-primitive type you specify: any class type, any interface type, any array type, or even another type variable. 如您所见,所有出现的Object都被T替换。类型变量可以是您指定的任何非基本类型:任何类类型,任何接口类型,任何数组类型,甚至是另一个类型变量。

You can learn further here 你可以在这里进一步学习

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

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