Static call non-static Method!! This is unthinkable in the java,c#, and absolutely not. Such errors are indicated incorrectly in these languages during the compilation phase. But what about dynamic languages like PHP? First of all, this is a grammar
Problem Source: an interesting problem was found yesterday when I gave my younger brother a tutoring of the data center charging system. It is BLL and Dal layers. layer D is a static method. When layer B calls the method of layer D, it is called
Today, I saw the interesting question: what is the difference between locking and non-static methods on static methods, so that some understanding of the lock mechanism is introduced again.First look at the method:This is a very simple class that
PHP can call non-static methods in static form. This post was last edited by lytreo650 in 2014-03-1410: 05: 21 & lt ;? Phpclass & nbsp; test & nbsp; {public & nbsp; function & nbsp; sayHello & nbsp; () & nbsp; {echo PHP can call non-static methods
Public class Outer {
Public string name = "outer ";
Public static void main (string argv []) {
// Inner myinner = new inner (); // compilation error occurs when you use this statement directly.
Outer myouter = new outer (); // first create an
Such as:public class innerclassdemo{int x;Class a{static int a = 0;//is not legal to write this way.static final int b=0;//It's legal to write this.}}Answer: to put it simply, define a static domain or method that requires a static environment or a
Static initialization is performed only once, and instance initialization is performed every time the instance is created.1. Create a spoon class: Package com.samsung.wx; Public class Spoon { System.out.println ("Static
Static call of non-static methods !! This is unimaginable in java and c #, and it is absolutely impossible. Such errors will be pointed out during the compilation phase in these languages. But what about dynamic languages like php? First, there is
The Synchronized keyword is a solution that is provided in Java concurrency Programming in order to solve the problem caused by threads competing for shared resources. There are two uses of the Synchronized keyword, one for the definition of the
Java static methods, static variables generate a unique identity when called, that is, a static seat is given in memory so that it can be found directly at the time of invocation and saves memory. However, if the declared static method, too many
Until one day, I started piecing together Dom tags in js, and I needed to keep piecing together, and I found that my code was getting ugly, not only about the simplicity of the code, but sometimes the performance problems. Over the longer term, in
The static field is declared with the static modifier, and the other fields are non-static fields. Static and Non-static fields belong to static and non-static variables in C #, respectively.
If a field is described as static, there is only one
Static class: A class that contains a static definition of the
Static PropertiesOr the class of the method
Static Class access Methods:
1, the static method does not need to instantiate the object, can be called directly through the class name, the
The difference between static and non-static methods used in Java synchronizedIn Java, synchronized is used to represent synchronization, and we can synchronized to modify a method. You can also synchronized to modify a block of statements inside a
name; } Public Function GetName () { $this->echoname () }}} class newclass{ private $name = "Newclass"; Public Function Echoname () { echo $this->name; } Public Function test () { myclass::getname ();
First, static members are initialized during class loading, and the classloader of JVM is loaded. For the first time, they actively use loading, rather than static members are creating objects, it is initialized only when the new operation is
Static member functions cannot access non-static member functions.
The static member function does not include the this pointer.
The non-static member function implies the this pointer. To call a non-static member function, this pointer is
One day, I began to piece together DOM labels in js, and I had to keep piecing together. I found that my code had become increasingly ugly, not only the problem of concise code, sometimes it also causes performance problems. In the long run, in less
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.