I'm creating a custom array class, and it has an int property size.
This property is modified automatically if you do something like add() or remove(). I want to let the user read this property like myArray.size. However, making it public allows the user to change it, which doesn't make much sense for my class, and could break it.
I could of course make it private and create a getter method size() and all's good. I don't have a problem with that, but still, is there a way to make a read-only property in Java?
Looking around the web, I found this:
Their solution goes like
public final String title;
Which is tecnically valid, but that of course doesn't work for my array, since my property is not constant.