java中的final
来源:互联网 发布:简单的java反转字符串 编辑:程序博客网 时间:2024/05/19 01:07
The final keyword can be applied to classes, methods, or fields.
When applied to a class, it means that the class cannot be subclassed. 不能被继承
When applied to a method, it means that the method cannot be overridden by a subclass. 不能被重载
When applied to a field, it means that the field's value must be assigned exactly once in each constructor and can never change after that. 但是这里只针对基本类型有效
While an array reference can be declared as final, the elements of the array cannot. This means that classes that expose public final array fields or return references to those fields through their methods.
Similarly, while an object reference may be declared as a final field, the object to which it refers may still be mutable. If you wish to create immutable objects using final fields, you must prevent references to arrays or mutable objects from escaping from your class.
final string can not be changed with replace method(replace method just reture a new string)
When applied to a class, it means that the class cannot be subclassed. 不能被继承
When applied to a method, it means that the method cannot be overridden by a subclass. 不能被重载
When applied to a field, it means that the field's value must be assigned exactly once in each constructor and can never change after that. 但是这里只针对基本类型有效
While an array reference can be declared as final, the elements of the array cannot. This means that classes that expose public final array fields or return references to those fields through their methods.
Similarly, while an object reference may be declared as a final field, the object to which it refers may still be mutable. If you wish to create immutable objects using final fields, you must prevent references to arrays or mutable objects from escaping from your class.
final string can not be changed with replace method(replace method just reture a new string)
- java中的final
- java 中的final意义
- java 中的final意义
- java 中的final意义
- java中的final
- java中的final
- Java中的final关键字
- java中的final
- JAVA中的关键字FINAL
- java中的final用法
- Java 中的final
- java中的final变量
- java中的final关键字
- JAVA中的final
- 关于Java中的final
- 关于Java中的final
- java中的final
- 关于Java中的final
- 精简版CE串口类库
- HTML5新手入门指南
- 6.大数相加优化---
- LZ77算法基础介绍
- Eclipse插件下载地址大全
- java中的final
- com.googlecode.jsonplugin.JSONException: java.lang.reflect.InvocationTargetException解决方法
- MyEclipse常用的几个快捷键
- C#实现系统托盘,C#窗体最小化时隐藏为任务栏图标
- 【学习笔记】事故案例视频音像资料库平台。。学习中
- MVC学习笔记之入门篇(三)mvc3集合使用实体框架Entity Framework
- 个人比较喜欢的flash小游戏
- 外接球算法
- hdu 1005 找规律(循环点)