In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "what are Java inner classes and anonymous classes". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what Java inner classes and anonymous classes are.
I. Internal class
Basic knowledge:
A class that contains an inner class is called an embedded class of that inner class.
The member variables of the embedded class of the inner class are still valid in the inner class, and methods in the inner class can also call methods in the embedded class.
The class body of an ordinary inner class cannot declare class variables and class methods (static-decorated inner classes can, and such inner classes are often called nested classes). An inner class can be used in the body of an embedded class to declare an object as a member of the embedded class.
An inner class is only useful for its embedded class, and other classes cannot declare objects with the inner class of a class.
The name format of the internal class corresponding to the bytecode file: the embedded class name $internal class name.
The static inner class is a static data type in the embedded class, so that you can use the static inner class to create objects in other classes, but the static inner class cannot manipulate instance members in the embedded class.
An anonymous class must be an inner class, because it must create an object directly in a class.
An anonymous class is a subclass and does not have a class name, so when creating an object, you directly apply the constructor of the parent class.
II. Expansion in the book
Control framework: a special kind of application framework, which is used to solve the requirements of responding to events. the system that is mainly used to respond to events is called event-driven system. One of the common problems in application design is the graphical user interface (GUI), which is almost all event-driven systems.
Application framework: a class or set of classes designed to solve a particular type of problem. To use an application framework, you usually inherit one or more classes and override certain methods. In the overridden method, write code to customize the general solution provided by the application framework to solve your specific problem.
Template method: contains the basic structure of the algorithm, and one or more overlay methods are called to complete the action of the algorithm.
Design pattern: always separate the changed things from the things that remain the same, in this pattern, the template method is the same thing, and the overlay method is the changed thing.
At this point, I believe you have a deeper understanding of "what are Java internal classes and anonymous classes". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.