(1).接口不是类,所以不能用接口创建对象,即不能用new运算符。
x = new Comparable(); //错误
(2).可以声明接口类型的引用,该引用只能指向实现了该接口的对象。
class Student : Comparable {...}
Comparable x = new Student();
已有 22658 名学员学习以下课程通过考试
最需教育客户端 软件问题一手掌握
去 App Store 免费下载 iOS 客户端
点击加载更多评论>>