Learn about why constructor cannot final in java, we have the largest and most updated why constructor cannot final in java information on alibabacloud.com
Java Memory Model-final, java model-final
Compared with the locks and volatile described earlier, the read and write operations on the final domain are more like common variable access. For final domains, the compiler and processor must follow two
Why use the this constructor and the this constructor?
When a class has multiple constructors, this constructor is often used:
public class SomeClass{ public SomeClass() {// TODO: Initialize some fields } public SomeClass(string temp) :
Please read the following procedure:
public class hello{
public static void Main (string[] args) {//(1)
System.out.println ("hello,world!"); (2)
}
}
Read this program, for most of the learning Java from, are not unfamiliar. Even if you
Java static, this, super, final usage
I. Static
Take a look at the following program:
Public class Hello {Public static void main (string [] ARGs) {// (1)System. Out. println ("Hello, world! "); // (2)}}
I have read this program,
Compared to the lock and volatile described earlier, the read and write to the final domain is more like normal variable access. For the final domain, the compiler and processor are subject to two reordering rules:
Writing to a final field
Final classwhen a class is defined as final class, it means that the class cannot be inherited by other classes, that is, it cannot be used after extends. Otherwise, errors are obtained during compilation.
Package Com.iderzheng.finalkeyword;
This article belongs to author original, the original text is published in Infoq:http://www.infoq.com/cn/articles/java-memory-model-6Compared to the lock and volatile described earlier, the read and write to the final domain is more like normal
This article transferred from: http://www.infoq.com/cn/articles/java-memory-model-6Compared to the lock and volatile described earlier, the read and write to the final domain is more like normal variable access. For the final domain, the compiler
Compared to the lock and volatile described earlier, the read and write to the final domain is more like normal variable access. For the final domain, the compiler and processor are subject to two reordering rules:
Writing to a final field
Compared to the lock and volatile described earlier, the read and write to the final domain is more like normal variable access. For the final domain, the compiler and processor are subject to two reordering rules:
Writing to a final field
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.