[英]What's th mean by “public abstract class SampleAdapter <T extends Adapter> extends ViewGroup”?
I am not getting meaning by 我的意思不是
public abstract class SampleAdapter <T extends Adapter> extends ViewGroup
What does it do? 它有什么作用? In general we perform normal inheritance, but here something extended form.
通常,我们执行正常的继承,但是这里有一些扩展形式。 can any body suggest me?
有人可以建议我吗?
thanks 谢谢
This declares a class SampleAdapter
that: 这将声明一个类
SampleAdapter
:
T extends Adapter
: T extends Adapter
:
The class SampleAdapter
takes a class parameter T
that should extend Adapter SampleAdapter
类采用应扩展Adapter的类参数T
example : 例如 :
ArrayList A = new ArrayList<String>();
String
is parameter for ArrayList. String
是ArrayList的参数。
SampleAdapter A = new SampleAdapter<parameterClass> ();
parameterClass is parameter for SampleAdapter (which is T) and it must extend Adapter : parameterClass是SampleAdapter的参数(它是T),它必须扩展Adapter :
public class parameterClass extends Adapter{//must extend Adapter
As for abstract
, it says that class SampleAdapter
is a class that can't be instantiated directly but rather must be extended by another class. 至于
abstract
,它表示SampleAdapter
类是一个不能直接实例化的类,而必须由另一个类扩展。
abstract
is referring to a class that can't be instantiated directly, usually because of some methods that need to be implemented in an extending class. abstract
是指无法直接实例化的类,通常是因为某些方法需要在扩展类中实现。
You'll have to implement those abstract
methods in the subclass, otherwise your code won't compile. 您必须在子类中实现这些
abstract
方法,否则您的代码将无法编译。
abstract
means that the SampleAdapter
class cannot have any objects, <T extends Adapter>
means, that the SampleAdapter
class is used as a container for objects of any class, that extends Adapter
. abstract
表示SampleAdapter
类不能有任何对象, <T extends Adapter>
表示SampleAdapter
类用作扩展Adapter
的任何类的对象的容器。 Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.