Note of 《thinking in java》5

5. Hiding the Implementation

  1. A primary consideration in object-oriented design is "separating the things that change from the things that stay the same."
  2. There can be only one public class in each compilation unit, otherwise the compiler will complain.
  3. A working program is a bunch of .class files, which can be packaged and compressed into a Java ARchive(JAR) file(using Java's jar archiver).
  4. The Java interpreter finds the environment variable CLASSPATH(set via the operating system, and sometimes by the installation program that installs Java or a Java-based tool on your machine).
  5. The CLASSPATH can contain a number of alternative search paths.
  6. When the compiler encounter the import statement for the current library, it begins searching at the directories specified by CLASSPATH.
  7. All objects can easily be force into String representation by putting them in a String expression.
  8. Don't make the mistake of thinking that Java will always look at the current directory as one of the starting points for searching. If you don't have a '.' as one of the paths in your CLASSPATH, Java won't look there.
  9. You might not initially think you'll use the private keyword often since it's tolerate to get away without it. (This is a distinct contrast with C++.)
  10. A reference to an object is private inside a class doesn't mean that some other object can't have a public reference to the same object.
  11. Since the default constructor is the only one defined, and it's private, it will prevent inheritance of this class.
  12. Sometimes the creator of the base class would like to take a particular member and grant access to derived classes but not the world in general. That's what protected does.
  13. Classes browsers have become an expected part of any good Java development tool.
  14. Note that a class can not be private(that would make it accessable to no one but the class) or protected.
  15. If you don't want anyone else to have access to that class, you can make all the constructors private, thereby preventing anyone but you, inside a static member of the class, from creating an object of that class.
  16. Actually, an inner class can be private or protected, but that's a special case.
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值