,
有两点值得注意:
1。System.in是BufferedI utStream。
只需要通过System.in.getCla ().getName()即知。
2。设计API时需要重视的一点就是方法的返回值和传入参数应当尽量声明为Interface或
者是a tract cla 。
这样做的优点是API设计者可以在以后替换具体的实现类,只要他们都implements/e
xtends了同样的interface/a tract cla 。
从而一方面保证了API的向后兼容性,同时也达到了提高性能/修复bug等目的。
Please note that the cla type declared in API may be totally different wit
h the actual cla type in the runtime.
Finding a OO book then reading the chapter on polymorphism will be very help
ful.
【 在 simeon (小猪~guliguli) 的大作中提到: 】


