21st: Using a Function object to represent a policy
This one does not actually say anything, is the strategy mode. When you encounter this scenario, define a policy interface, and then implement it with different policy subclasses, and the main class contains a reference to the interface.
22nd: Prioritize static member classes
A nested class refers to a class that is defined inside another class. The purpose of the nested class's existence should be to provide services only for its perimeter classes. There are four types of nested classes: Static member classes, non-static member classes, anonymous classes, and local classes. In addition to the first, three other types are called inner classes.
Sounds very round, in fact, the distinction is very simple.
First, if it is not inside the method, it is the member class (which, depending on the circumstances, should not be made static). Inside the method, that is, and there is a pre-set type that illustrates the nature of the class , which is the anonymous class. Local classes are rarely used.
Anonymous class Examples:
New Thread (new Runnable () { @Override publicvoid run () { // TODO auto-generated method stub } });
The static inner class example is shown in the builder in article 2nd.
Effective JAVA2 reading notes-classes and Interfaces (v)