thinking in java(VII)--interfaces and inner classes
2011-11-17 23:58
218 查看
C++中未包含这两种机制,因而其多重继承机制运用起来比较困难
interface就像是一种更abstract的class
内含数据成员组成一个常量群,函数有形式无实现
interface通过继承和组合来扩展
inner classes 的用途有名称隐藏,程序代码组织和连接外围对象
将inner classes置于任意程序范畴之内的理由
1.实现某种interface然后返回某个引用
2.用一个类解决一个复杂的问题,但你又不希望这个类被外界所用
额外性质:
1.inner class可以拥有多分实体
2.单一outter class内可拥有多个inner class
3.产生inner class对象的时间无须与outer class同时
4.inner class是独立个体
PS:撰写inner class时你并不会将任何东西加入outer class的接口或修改其接口
interface就像是一种更abstract的class
内含数据成员组成一个常量群,函数有形式无实现
interface通过继承和组合来扩展
inner classes 的用途有名称隐藏,程序代码组织和连接外围对象
将inner classes置于任意程序范畴之内的理由
1.实现某种interface然后返回某个引用
2.用一个类解决一个复杂的问题,但你又不希望这个类被外界所用
额外性质:
1.inner class可以拥有多分实体
2.单一outter class内可拥有多个inner class
3.产生inner class对象的时间无须与outer class同时
4.inner class是独立个体
PS:撰写inner class时你并不会将任何东西加入outer class的接口或修改其接口
相关文章推荐
- Java学习笔记(13)Abstract Classes and Interfaces
- Chapter 6 Interfaces and Inner Classes.md
- Shader Model 5 Interfaces and Classes
- When to use comparable and comparator interfaces in java
- Inner versus nested classes Java Interview Question
- Java classes and class loading
- Why do many Collection classes in Java extend the abstract class and implement the interface as well
- 对照Java学习Swift--类和结构体(Classes and Structures)
- thinking in java(V)--composition and inheritance
- The differences between Java EE components and "standard" Java classes
- Customize User Interfaces and Pass User Input to Installer Classes
- Java学习笔记(9)Objects and Classes
- [转] Difference between Abstract classes and Interfaces
- 设计: ListView 接口,and the missing read-only interfaces in java collection framework
- thinking in java(III)--initialization and cleanup
- Java 基础 —— Objects and Classes
- Hidden Gems in the Java APIs - Utility Classes and Methods
- Chapter 5 Nested Classes and Interfaces
- Thinking in Java之Interfaces
- Thinking in Java(8)-inheritance and cleanup