1.finalIn Java, the final keyword can be used to decorate classes, methods, and variables (including member variables and local variables). Here's a look at the basic usage of the final keyword in three ways.1. Modifier classWhen a class is
A brief analysis of final keywords in JavaWhen it comes to the final keyword, it's probably a lot of people who are not unfamiliar with the final keyword when using anonymous internal classes. In addition, the string class in Java is a final class,
When it comes to the final keyword, it's probably a lot of people who are not unfamiliar with the final keyword when using anonymous internal classes. In addition, the string class in Java is a final class, so today we'll look at the use of the
A. Final value of the variable cannot be changedB. Final methods cannot be rewrittenC. The final class cannot be inherited 1. Final classThe final class cannot be inherited, so the member methods of the final class have no chance of being
2017-11-05 15:08:47
Final keyword
The Java keyword final has the meaning of "This cannot be changed" or "final state", which can be used to modify non-abstract classes, non-abstract class member methods, and variables.
There
1. Final variable
Final variable is a constant that cannot be changed once it is initialized.
Class Test1 {
final double PI = 3.14;//The name of the constant is best capitalized public
Test1 () {
PI = 3.14;
}
void Test () {
Directory
Basic usage of the final keyword of the catalog 1 modifier class 2 modifier 3 modifier variable in depth discussion of final and ordinary variables in final keyword 1 class 2 The object content of the final modified reference variable is
1, the final basic usage1.1. Cosmetic classWhen a class is decorated with final, it indicates that the class cannot be inherited. In other words, if a class you never let him be inherited, it can be decorated with final. The member variables in the
The final keyword in Java is used to restrict the behavior of the user, in other words, to restrict our programmers. Final can be used to modify: variables, methods, classes.1) Java final variableWhen final is used to modify a variable, the value of
Void testn (int n){N = 0; // correct, but the external N value has not changed. Be careful about logical errors.}
Void testn (const int N){N = 0; // compilation error. Adding const can prevent logical errors.}
Void testn (int * n){N = new int (
When it comes to the final keyword, it's probably a lot of people who are not unfamiliar with the final keyword when using anonymous internal classes. In addition, the string class in Java is a final class, so today we'll look at the use of the
The final keyword gives the most obvious is fixed, can be modified class, method, variable. after modification, the class is not inheritable, the method is not overwritten, and the variable is immutable. Note: The private method of the class is
When you use final action on a member variable of a class, the member variable (note is the member variable of the class, the local variable needs to be guaranteed to be initialized before use) must be assigned in the definition or constructor, and
First, finalDepending on the context of the program, the Java keyword final has the meaning of "This cannot be changed" or "final state", which can be used to modify non-abstract classes, non-abstract class member methods, and variables. You may
First, FinalDepending on the context of the program, the Java keyword final has the meaning of "This cannot be changed" or "final state", which can be used to modify non-abstract classes, non-abstract class member methods, and variables. You may
First, finaldepending on the context of the program, the Java keyword final has the meaning of "This cannot be changed" or "final state", which can be used to modify non-abstract classes, non-abstract class member methods, and variables. There are
Java variable naming convention]
Java is a case-sensitive language that distinguishes letters. The following describes the naming rules for packages, classes, and variables in Java.(1)Package)Name: the package name isA lowercase wordFor
When it comes to the final keyword, it's probably a lot of people who are not unfamiliar with the final keyword when using anonymous internal classes. In addition, the string class in Java is a final class, so today we'll look at the use of the
Http://zhidao.baidu.com/question/397935417.html1.final decorated classes cannot be inherited and have no subclasses."Use environment":1. Classes that are not specifically designed for inheritance have complex invocation relationships between the
It programmer development must-all kinds of resources download list, the most complete IT resources in history, personal collection summary. What is the difference between final, finally and finalize.This is a classic interview question, we can
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.