Final modifier, final Modifier
When final modifies a variable, it indicates that the variable cannot be changed once the initial value is obtained,The final variable cannot be assigned a new value after obtaining the initial value. Therefore, the
Final is literally understood to mean "last, final". This is also true in Java.
Final can be used to modify variables (including class properties, object properties, local variables, and formal parameters), methods (including class methods and
The final modifier in Swift prevents the class from being inherited and also prevents subclasses from overriding the properties, methods, and subscripts of the parent class. It is important to note that the final modifier can only be used for
1. Design pattern: A problem-solving idea. The most effective way to solve a certain kind of problem. Java has 23 design patterns (summed up by predecessors).
Single-Example design pattern: Resolves a class that has only one object in memory.
if a
The final modifier and Javafinal modifier in Java
1. When can I select the final modifier?
If you want to prevent a class from being inherited by other classes and are not allowed to have child classes, you should consider using final for
Java Basics-Stack and heap, static, final modifier, inner class, and Java memory allocation (RPM)Java Stack and heapHeap: Random in orderStack: LIFO (last-in/first-out).The Java heap is a run-time data area in which the objects of the class allocate
/*Final (final, modifier) Final keyword usage: 1. When the final keyword modifies a variable of a primitive type, the variable cannot be re-assigned, and the first value is final. 2. When the FIANL keyword modifies a reference-type variable, the
[JAVA] final modifier Field, javafinalfield
I. Introduction
The final modifier can be used to modify variables, methods, and classes. The final variable cannot be changed once it is assigned a value.
Ii. final member variables
Member variables are
Use of 1.final modifiers:
Final can modify the variable, and after the final modified variable is assigned the initial value, it cannot be re-assigned.
Final can modify the method, and the final modified method cannot be overridden.
Static, final modifier, internal class, staticfinal
Static modifier:The static modifier can be used with attributes, methods, and internal classes to indicate static. Static variables and static methods in the class can be used together with the
Java programming things 66-Final Modifier
Chen yuefeng
From:Http://blog.csdn.net/mailbomb8.7.2 final
The final keyword is the final and final meaning. It can be used in a program to modify the declaration of classes, member variables, and methods.
The final keyword can be used to modify classes, variables, and methods.
When final modifies a variable, it means that the variable cannot be changed once the initial value is obtained.
Final member Variable
The final decorated class field, where
The final keyword before the method parameter is to prevent the data from being modified in the method body. There are two main cases: first, the basic data type is decorated with final, and second, the reference type is decorated with final.In the
Public class finaltest {Public String findword = "final word"; public final stringbuffer sfindword = new stringbuffer ("final word "); /*** @ Param ARGs */public static void main (string [] ARGs) {finaltest Ft = new finaltest (); system. out.
Final as a modifier, you can decorate classes, variables, functions. 1, the final modified class can not be inherited (protection of encapsulation), in order to avoid being inherited, quilt class replication; 2, the final modified function can not
Master Do not spray ~The final keyword can be used to decorate classes, variables, and methods, which have the meaning "This is immutable" or "final", so the final decorated classes, variables, and methods will have the following characteristics:A 1.
The final keyword before the method parameter is to prevent the data from being modified in the method body.There are two main cases: first, the basic data type is decorated with final, and second, the reference type is decorated with final.In the
The final modifier variable cannot be changed, or the referenced object cannot be changed.
Check the Code:
1 package pnunu. oa. test; 2 3 public class TestFinal {4 public static void main (String [] args) {5 final StringBuilder sb = new
JAVA_SE basics -- 42. final Modifier
Do not spray ~
The final keyword can be used to modify classes, variables, and methods. It has the meaning of "This cannot be changed" or "final, therefore, the classes, variables, and Methods Modified by final
1. if a property field is modified in static mode, this property field becomes a resource of the class, and the public field is modified to a common one. You can use test outside the class. a. if it is modified to private, it can only be used within
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.