There are four internal classes:
1. static internal classes can only use static members in external classes, which is of little use.
2. The member internal class is similar to the external class attributes and methods in parallel. It can call the attributes and methods of the external class and is fully useful.
3. Internal class of the method, defined in the method, can access attributes and methods in the peripheral class, and final constants in the method. It's useless, because the fourth one is easier than him.
4. Anonymous internal classes, which are most used, are implemented through extended interfaces or other classes. The usage is the same as that of internal classes of methods, which is easier to write.
Why use internal classes? In short, it makes sense when the class and its class or method are together. If it is separate, it does not make sense. Therefore, it is defined in the class or method.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service