C # differs greatly from Java in understanding the static keyword, mainly in the internal class. In addition, because JAVA does not have a data structure similar to delegate, internal classes must take important responsibilities such as
1. Anonymous internal class
Anonymous classes cannot be referenced because they cannot have names. They must be declared as part of the new statement at creation. This requires another form of new statement, as shown below: New in this form of
JAVA internal class
1. Common internal classes (internal classes are not static)
The internal class can access all the members of the peripheral object. When an internal class object is created for a peripheral class object, the internal class
As shown in the example, a partial internal class timerprint is declared. The method in this class references a local variable testtxt, which must be declared as final !!Why?
Logically:This internal class appears inside a method, but during actual
JAVA Inner class
One, what is the internal class?
The definition of a class is placed inside another class, and this class is called an inner class
What are the characteristics of the inner class?
1. The inner class is still a separate class,
1. Definition:The definition of a class is placed inside the definition of another class, and the class that contains the inner class is called the outer class
2. The role of the internal class:
(1) The inner class provides a better encapsulation
Internal class,
In a class, apart from defining normal variables and methods, a class is defined in the class, and the class in that class is an internal class.
The internal class can be modified in private or static mode when it is in the
When I watched the video of Mars yesterday, I was ashamed of seeing that he was talking about anonymous internal classes. So Baidu + Google finally came up with the following:
Anonymous internal class
1. Definition: As the name implies, an internal
1: Problems with formal parameters and return values (understanding)(1) Formal parameters:Class Name: An object that requires this classAbstract class Name: A subclass object that requires this classInterface Name: An implementation class object
// 2004-9-18Summary of internal classes:
1. the nesting of internal classes can be understood as the link between classes. When constructing an internal class (non-static) instance, the instance of the outer class will be directlyAs a parameter is
Abstract methods and abstract classes Abstract methods and abstract classes must be modified using abstract. classes with abstract methods can only be defined as abstract classes. abstract classes can have no abstract methods.Rules they follow:1.
An anonymous internal class is an internal class without a name.
Because there is no name, the anonymous internal class can only be used once. It is usually used to simplify code writing.
However, to use an anonymous internal class, you must inherit
In a blog: "Analysis of the Role of Java internal classes", you can understand some of the Java internal classes, but there are some points in the internal classes that deserve our careful research...
The following are some of the Java internal
Member internal class ----- equivalent to a member of the class ----- if the internal class is not private, you can directly create an object outside the class, Outter external class, Inner internal class
----- Outter. Inner a = Outter. new Inner ();
Java anonymous internal class js closure, javajs
Recently, when I saw closure (closure) in Javascript, I thought that both of java's anonymous internal classes involved variable/parameter references.
Let's first talk about the anonymous internal
1. Memory Allocation in Java
JavaProgramDuring runtime, the memory structure can be divided into method, stack, heap, and local method stack (called by JNI in Java.
JVM allocates a stack (method stack) for each running thread. The stack stores
An anonymous internal class is an internal class without a name (in fact, there is no name at the code layer, but an anonymous class also has a name at the bytecode level)
Because there is no name, the anonymous internal class can only be used
Http://blog.csdn.net/fhm727/article/details/5220003
1. What is an anonymous internal class?
An internal class exists in another class, while an anonymous internal class, as its name implies, is an internal class without a name.
2. Why do
First, define the concept of closure: A code segment is used as a parameter of the method.Java does not directly use a method as a parameter for another method. Java uses an anonymous internal class to simulate this situation.
Anonymous internal
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.