Are all final classes in Java immutable. String and Integer both are final classes and both are immutable i beleive.
As has been said by the others before final
does not make a class imuutable in Java though it plays a part in the immutability strategy. To obtain immutability you should follow the general guidlines:
final
, or use static factories and keep constructors private private
and final
setXXX
methods (that is, avoid the Java Beans convention) setXXX
methods, but any method which can change state