The Java keyword final has a final, immutable meaning that modifies non-abstract classes, non-abstract class member methods, and variables.
Error: Class "Testfinal" is either abstract, or final, not both.
1.final decorated classes are the ultimate. You cannot inherit from another class, there is no subclass.
2. Because the final class has no subclasses, the methods in the final class cannot be overwritten, so the
All methods and variables are final, and there is no need to explicitly declare a method final.
Public Final classtestfinal{ Public Static Final intI=1;//the data members in the final class can be final protected intJ//the data members in the final class may not be final Public voidF () {}//the method in the final class is final and may not be explicitly declared Public Final voidg () {}//the methods in the final class can be declared final, but it doesn't make sense .}
3.The final method cannot be overridden by a method of a class, but can be inherited.
Public class extends finalonmethod{ publicstaticvoid main (string[] args) { testfinal Tfinal=new testfinal (); Tfinal.one (); }} class finalonmethod{ publicfinalvoid One () { System.out.println ("Hello, I am a final method, but I am in a class that has no final modification oh!!!!!!!!!!!!!" ); }}
Let's rewrite how this is done by the final modification.
The error is at compile time.
Thus we associate the private method with the non-inheritance.
Because the system considers private members as final. We can also represent a private member as FIANL. But it doesn't make any sense.
4. The final member variable represents a constant, can only be assigned once, the value is no longer changed after the assignment, and a compilation error occurs if forced assignment.
5.final cannot be used to modify the construction method. The constructor method does not exist, it cannot be overridden, that is, the construction method itself is final, and there is no need to use the final label.
Final summary in Java