Are all final class immutable?

前端 未结 8 2304
一生所求
一生所求 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:08

    Final keywords prevents the other classes to inherit it. Final keyword doesn't make it immutable but there are such condition as making the instance class members private as well final and by using getters and not using setters

提交回复
热议问题