类和接口

2018-01-07  本文已影响0人  李军_6eaa
在类和接口中,讲讲你对封装的理解?
对于top-level的类和接口,一共有哪些access levels?
对于成员(fields, methods, nested classes, nested interfaces),一共有哪些access levels?
fields, methods, nested classes默认的access levels 是什么?
interface members默认的access levels 是什么?
怎么解决array field 的access levels 问题?
private static final Thing[] PRIVATE_VALUES = { ... };
public static final List<Thing> VALUES =
   Collections.unmodifiableList(Arrays.asList(PRIVATE_VALUES));
private static final Thing[] PRIVATE_VALUES = { ... };
public static final Thing[] values() {
    return PRIVATE_VALUES.clone();
} 
public classes 为什么不应该暴露mutable fields?
immutable class的好处和缺点?
Java平台库包含哪些immutable classes?
实现一个immutable class,应该遵守哪几点?
相对于继承,为什么更赞同使用组合?
为什么相对于抽象类,优先使用接口?
怎么合理利用接口和抽象类?
java8中接口中的默认方法的优缺点?
为什么说接口只应该用于定义types?
不要写标签类(含switch),而去写类层次
相对于非静态成员类,为什么优先使用静态成员类?
不要在一个源文件中写多个top-level的类或者接口,否则容易形成恼人的Bug。

上一篇 下一篇

猜你喜欢

热点阅读