how to know if a class is immutable by Javadoc?

Asked

Viewed 35 times

1

I would like to know if by how, by Javadoc know whether a class is immutable or not. There is some field in Javdoc for quick query, as I am using several classes and do not have much contact with the language. I would like the answer and, if possible, an image. Thank you. I’m working with shapes. It would be nice if this class were used as an example.

  • Image of what you expect in the answer? I don’t understand.

  • https://stackoverflow.com/a/5124214/5524514

1 answer

1


You should look at whether the constructor is private, it is generally recommended to use it privately and create a public method of() that returns a new object. If she has setters, if she doesn’t have you you won’t be able to change values.

  • A class can be immutable and have public constructor. See for example String.

  • You can! I’ll adjust the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.