Java中static和final是什么意思
时间: 2023-05-29 22:04:00 浏览: 101
static和final都是Java中的关键字。
static表示静态的,可以修饰变量、方法和代码块。静态变量属于类,不属于对象,可以通过类名直接访问,也可以通过对象访问。静态方法也属于类,不属于对象,可以通过类名直接调用,也可以通过对象调用。静态代码块在类加载时执行,只执行一次。
final表示不可变的,可以修饰变量、方法和类。final变量只能赋值一次,不能被修改。final方法不能被子类重写。final类不能被继承。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)