Java class loading sequence and java Loading Sequence
Java class loading sequence
I. Loading Sequence
1. initialize static member variables of the parent class
1.1 static code block
1.2. Common Code Block
1.3 No parameter Constructor
2. Static
Understand the memory, understand everything, understand a variety of languages. All the languages are like this: The local variable allocation memory is always inside the stack, new out of the allocated memory is always in the heap, static things
First, the Static keyword The member variables in the original class, each new object, has a member variable of its own, because these member variables are not static member variables. For static member variables, there is only one copy of this
One, static key word
The original member variable in a class, each new object, this object has a member variable of its own, because these member variables are not static member variables. For a static member variable, this member variable has
Java internal class, Java
Package innerclass; // in Java, a class can be defined in another class or method. Such a class is called an internal class. In a broad sense, internal classes generally include the following four types: member Internal
So far, all the member variables and member functions in the class we have designed are objects, such as the book class we defined earlier, using the book class to declare two objects Alice and Harry, both of which have their own price and title
The static in C + +There are two uses for static in C/C + +: Static in process design and static in object-oriented programming. The former applies to ordinary variables and functions, and does not involve class problems.A. Static keywords for
Static keywords, which must be learned by java, are hard to understand when many friends write and read code. The following describes how to learn static keywords.
I. static keywords
The original member variables in a class, each new object,
// The ClsPublic class in the dynamic link library has a variable private static string key = "1111 ";// Modify and obtain the value through the reflection technique below// Set the keyPublic static void updatePalmKey (string key = "test")
Nested classes allocate reclaimed memory:
#include
#include
Class CA
{
Public
inline static CA *getinstance (void)
{
ASSERT (M_instance!= NULL);
return m_instance;
}
void Print (void)
{
Puts ("Check the print function of the main
Summary of the use of C + + static member variables and static member functions:
one. Static member Variable:A data member in a class body is preceded by a static keyword, and the data member becomes a statically data member of the class. As with
In Java serialization, two member variables cannot be serialized. One is static and one is transient.
But when I wrote a demo, I found that "static member variables can actually get".
The demo code is as follows
Package Com.java;
Import java.io.*
PackageInnerclass;//In Java, a class can be defined inside another class or inside a method, and such a class is called an inner class. The broad sense of internal classes generally includes these four types: member inner class, local inner class,
C + + static member functions
Like a data member, a member function can also be defined as static, and the preceding addition of a function in a class becomes a static member function. Such as
static int volume ();
As with static
1 Static member variablesvariables defined in a class are often referred to as member variables if the modifier is added to the front of a member variable Static , then we call this member variable a static member variable. 1.1 methods
In general, if there are N homogeneous objects, each object has its own member variable, and the member variables of the different objects have their own values, which are irrelevant to each other. But sometimes we want to have one or several member
Learn the idea of Java programming--class initialization p146The order in which classes are loaded* 1 Loader startup find Xxx.class file, search base class by extends keyword, load base class first* Class 2 initialization initializes static member
in C + +, there are two kinds of member variables: static and non-static, with three member functions: static, non-static, and virtual. So how do they affect the distribution of C + + objects in memory? When there is inheritance, what about its
First, final keywordsThe advent of inheritance increases the reusability of code and facilitates development. However, there are problems, some classes do not want to be inherited after the description, or some of the methods in the class function
Question: How do you count the number of objects? (1) Common member variables? No, because for normal member variables, objects have their own member variables, and they are independent of each other, so it is not possible to count the number of
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.