Are all final class immutable?

前端 未结 8 2733
一生所求
一生所求 2021-02-19 09:34

Are all final classes in Java immutable. String and Integer both are final classes and both are immutable i beleive.

8条回答
  •  自闭症患者
    2021-02-19 10:19

    No, final means the class can not be extended. It says nothing about mutability. For example:

    final class MutInt {
       public int modifyMe;
    }
    

提交回复
热议问题