title: how to define public variable in java which cannot be modified
body: <p>I would like every object of a class be able to access a class variable but don't want to get modified outside class.
  For example the way Array.length is used.</p>
  
  <p>But would also like to have a method in class which conditionally modifies this variable.</p>
  
  <p>Basically this usage is for a resizing object array implementation, where length of object array can change dynamically.</p>