http://www.importnew.com/7553.html

 

final Integet len = 10;

len = 100;

这样编译通不过,因为final指向的对象修改,但是final变量不可以指向新的对象,这里的赋值操作,就是指向了新对象。 

 

final Test test = new Test();

test.setLen(100);//可以运行

test = new Test();//出错,final修饰的变量,不可以指向其他对象。

 

 

其他还要注意的:

final方法(子类不可以修改)

final类 (如String等)

相关文章:

  • 2021-08-16
  • 2022-02-03
  • 2021-11-07
  • 2022-01-20
  • 2022-01-07
  • 2021-06-10
猜你喜欢
  • 2022-01-17
  • 2021-10-04
  • 2021-06-19
  • 2021-11-16
  • 2021-12-28
相关资源
相似解决方案