5. Hiding the Implementation
- A primary consideration in object-oriented design is "separating the things that change from the things that stay the same."
- There can be only one public class in each compilation unit, otherwise the compiler will complain.
- 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).
- 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).
- The CLASSPATH can contain a number of alternative search paths.
- When the compiler encounter the import statement for the current library, it begins searching at the directories specified by CLASSPATH.
- All objects can easily be force into String representation by putting them in a String expression.
- 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.
- 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++.)
- 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.
- Since the default constructor is the only one defined, and it's private, it will prevent inheritance of this class.
- 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.
- Classes browsers have become an expected part of any good Java development tool.
- Note that a class can not be private(that would make it accessable to no one but the class) or protected.
- 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.
- Actually, an inner class can be private or protected, but that's a special case.