The initialization Object Sequence in Java, the usage of Static code blocks, and the usage of Static code blocks
(1) differences between static methods for java static code blocksGenerally, if some code must be executed when the project is started, a static code block is req
(i) Java static code block static method differencesIn general, if some code must be executed at the time of project startup, the use of static code blocks, the code is active, it needs to be initialized when the project is started, in the case of not creating the object, other programs to invoke, the need to use a static
1. From the scope view:1> Global variables have global scope. A global variable can be used for all source files simply by defining it in one source file. Of course, other source files that do not contain global variable definitions need to declare the global variable again with the extern keyword.2> static local variable has a local scope, it is initialized only once, since the first time it was initialized until the end of the program runs, it diffe
A static member cannot be assigned in the class body because it is shared by all objects of that class. You assign a value to it in an object, and that member of the other object
will also change. To avoid confusion, it is not necessary to assign a value in the class body
When a data member of a class is declared static, the static data member can only be defined
Static keywords in C language and static keywords in C Language
In C, "static" can be used to modify both functions and variables. The following functions are provided in detail:
1. static modifier. If the project contains multiple source files and the function is declared as stati
Java Tour (Fri)--this,static, keyword, main function, encapsulating tool class, generating Javadoc manual, static code block
Have a lot of weekend, continue to study
One. this keyword
Used to distinguish between local variables and member variables with the same name
Features of thisThis represents the object of this class
It's in our set method.
publicvoidsetName(Str
(i) Java static code block static method differencesIn general, if some code must be executed at the time of project startup, the use of static code blocks, the code is active, it needs to be initialized when the project is started, in the case of not creating the object, other programs to invoke, the need to use a static
(i)Java static code block static method differencesIn general, if some code must be executed at the time of project startup, the use of static code blocks, the code is active, it needs to be initialized when the project is started, in the case of not creating the object, other programs to invoke, the need to use a static
------Object-oriented-knowledge about static (static)You can use the static keyword to declare variables, methods, or blocks of code that are not related to the class, but not to the instance. Static variables:When you write a class, you are actually describing the behavior and properties of its objects, and only by us
(1) differences between static methods for Java static code blocksGenerally, if some code must be executed when the project is started, a static code block is required. This code is actively executed and needs to be initialized when the project is started, when other programs call an object without creating an object, a stati
When a data member of a class is declared static, the static data member can only be defined once, and is shared by all objects of the same kind. Each object has a copy of every regular data member in the class, but only one instance of the static data member exists, regardless of how many class objects are defined. A static
What this section explains
static properties and Static methods
Access modifiers
Single-Case mode
Magic method
Automatic loading of classes
Objective
In the previous section, we introduced the basic object-oriented use, but the knowledge in the last section, in fact, there are problems can not be solved, such as we go to buy tickets, there is a total number of votes (the definition of
Reference: 1StaticmethodvsNonStaticmethodbytes. comtopicphpanswers495206-static-method-vs-non-static-method2PHPstaticmethodperformancevega.rd.noarticlesphp-static-method-performancephp is a very strange language. Of course, this is just for learning
Reference: 1 StaticmethodvsNonStaticmethod http://bytes.com/topic/php/answers/495206-
Static variables are also called class variables, and static methods are also called class methods.
Simply put, a static variable is a variable that all objects share. Static variables are also called class variables, and static methods are also called class methods.
How t
I have been reading the book
Title: static and non-static
Time: 2008-08-21
Content:
1. Static and non-static classes●. Static classes can only contain static members and static methods
static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated.">Static classes are basically the same as non-static classes, but there is one difference: Static classe
First, the syntax definition difference: the static keyword must be added before the static variable, but not before the instance variable.Differences during program running: instance variables belong to the attributes of an object. You must create an instance object. Only instance variables in the instance can be allocated space to use this instance variable. Static
The member variables between the object and the object are independent of each other. To share data, you need to use static members and static methods .
As long as you declare static member variables in a class, you can allocate space for static member variables, even if you do not define the object, and you can use
In this paper, we analyze the static static properties of the PHP object-oriented system and the call to it. It is easy to understand how they are called (whether they can be invoked or how they are invoked), and they need to understand where they are stored in memory. Static properties, methods (both static and non-
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.