The native framework of android uses a lot of c ++ Nested classes, while the java framework uses a lot of internal Nested classes. I have read some books and code to make a summary.
1. The non-static internal class of java has an external class reference outer. This variable can be used to reference all external variables, including private
2. Static java internal classes are also called Nested classes. static internal classes do not have external references, but they can only call external static methods and variables.
3. Anonymous internal classes are often used to write a listener, which is often used
New listener (){
Xx (){
}
};
4. the internal classes of c ++ are almost equivalent to syntax nesting, while the internal classes of C ++ cannot access the private variables of the external classes, to access the service, you must declare the external class as friend class www.2cto.com in the internal class.
From my current understanding, the nested class of c ++ is almost equivalent to a new class, and there may be some small differences;
Java internal classes are not just syntax nesting, but non-static internal classes have semantic relationships with the external, so external references must be established first.
From this point of view, the difference between the two is quite big.
From shcalm's column