Subclass a inherits the parent class B,a a=new a ();The correct order of execution is: parent class B Static code block, subclass a static code block, parent class B non-static code block, parent Class B constructor, subclass a non-static code block,
The memory partition of the Java Virtual machine: Java stack, heap, method area, local method stack, PC register. There is also the concept of a constant pool, where a virtual opportunity assigns a constant pool to each type, rather than an instance.
Static Call Non-static Method!! This is unthinkable in the java,c#, and absolutely not. Such errors are pointed out incorrectly in these languages during the compile phase. But what about dynamic languages such as PHP? First of all this is the
Copy Code code as follows:
Class A
{
Public
Static Functiona ()
{
Menber = 1;
}
Privateint menber;}
There was an error compiling the above code. The reason is simple, as you all know, static member functions cannot
Static variables:Static variables are declared with the static modifierCreated when the owning class is loadedAccess through a classThe same static variable for all instances of the owning class is the same valueNon-static variables:Variables not
The value type and reference type (Special string) Typeof and GetType () Use of static and non-static parameters to pass related knowledge, typeofgettype
Learning blog links: http://www.cnblogs.com/zhili/category/421637.html
1. Value Type and
Error cannot reference non-static variables from Static Context 20:58:52
Category: Java
What is "static "?
Anyone who has learned Java, C ++, or C should understand this keyword. The variable modified with this keyword is called a static variable,
1. The In-memory address is assigned as follows:We typically store value types in the stack, store reference types in the heap, and globally go to store static members.Value type: int char double bool decimal struct enum.Reference type: String
The difference between static and non-static classes1, in non-static classes can have instance members can also have static members2, in the call to use the image name. Instance member invocation (first to instantiate, such as Person ps=new Man ();
Knowledge Points: 1. Application of Getter and Setter 2. Local variables and member variables (also called global variables) 3.Static keyword usage A. Shared properties of all classes after the member variable is static modified B . After the method
#include using namespacestd;classTest { Public: Test (): X (0), Y (0) {CNT++; } intx; inty; voidPrint ()Const; Static intCNT; Static voidprint_s ();//a static member function cannot be set to a const function (CV qualifier???)};inttest::cnt
Exception handling Complete ProcessThe Main method calls a non-static method Public classdemo{ Public Static voidMain (string[] args) {// Static methods can be called by non-static methods//static methods can only call static methods//Demo d = new
The question of how to keep thread safe is not unfamiliar, either by using the synchronized and volatile keywords, or by using the lock provided in the concurrent package
link = = = = = =
The difference between synchronized and volatile please click
Problem: A field initializer cannot reference a non-static field, method, or propertyWhy is the field defined in the class not available because of an error in the following code?public class Test{Public Test (){}public int age=23;public int temp =
C # variable initialization problem: the initial value of a field cannot reference non-static fields, methods, or attributes,
Http://www.cnblogs.com/bluestorm/p/3432190.html
Problem: non-static fields, methods, or attributes cannot be referenced
This article mainly introduces the PHP class of constants, static properties, non-static properties of the difference and introduction, the need for friends can refer to the following
I. Class constants: Values that remain constant in a class are
static statically variable; Different objects share this variable's storage spaceInstead of static variables, each object has a variable memory spacepublic class Staticdemo {private int count=0;private static int staticcount=0;public Staticdemo ()
The difference between static and non-static1. In a non-static class, you can have either an instance member (non-static member) or a static member.2. When invoking instance members, you need to use the object name. Instance members;When you call a
Static static variables. Different objects share the memory space of this variable.
Instead of static variables, each object has a memory space for this variable.
public class StaticDemo {private int count=0;private static int staticCount=0;public
In 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 method. So what's the difference between static and non-static methods before
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.