创建抽象类和接口的对象 [英] create object of abstract class and interface
本文介绍了创建抽象类和接口的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人能告诉我如何创建抽象类和接口的对象。我所知道的是我们无法使用absract类和接口。
Can someone tell me that how can i create object of abstract class and interface. What i know is we cant intaniate the absract class and interface.
谢谢和问候,
gautam
Thanks and Regards, gautam
推荐答案
您无法实例化抽象类或接口 - 您可以实例化其子类/实现者之一。
You can not instantiate an abstract class or an interface - you can instantiate one of their subclasses/implementers.
示例这种事情在使用Java Collections时是典型的。
Examples of such a thing are typical in the use of Java Collections.
List<String> stringList = new ArrayList<String>();
您使用的界面类型列表< T>
作为类型,但实例本身是 ArrayList< T>
。
You are using the interface type List<T>
as the type, but the instance itself is an ArrayList<T>
.
这篇关于创建抽象类和接口的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文