在Java语法中,Class&lt ;?延伸东西> [英] in Java syntax, Class<? extends Something>

查看:122
本文介绍了在Java语法中,Class&lt ;?延伸东西>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

类< ;? extends Something>

这是我的解释,它是类模板,但类?意味着这个类的名字是不确定的,它扩展了Something类。

Here's my interpretation, it's class template but the class ? means the name of the class is undetermined and it extends the Something class.

如果我的解释有什么问题,请告诉我。

if there's something wrong with my interpretation, let me know.

推荐答案

你几乎是对的。
基本上,Java没有模板的概念(C ++有)。
这就是所谓的泛型。
这定义了泛型类 Class <> ,泛型属性是 Something

You are almost right. Basically, Java has no concept of templates (C++ has). This is called generics. And this defines a generic class Class<> with the generics' attribute being any subclass of Something.

我建议阅读如果你想获得模板和泛型之间的区别,那么C ++和Java中的泛型类型有什么不同?

I suggest reading up "What are the differences between "generic" types in C++ and Java?" if you want to get the difference between templates and generics.

这篇关于在Java语法中,Class&lt ;?延伸东西&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆