title: private String or public static String?
body: <p>At my internship one of my colleagues gave me a hint. I want to know if this is good practice.</p>
  
  <p>What I was doing was creating classes that are used only for the values they contain and don't have any functions that actually do something (apart from having getters, setters and a constructor). I declared my variables like this:</p>
  
  <pre><code>public class ObjectIUse{
    Private String name;
  
    public ObjectIUse(String name){
      this.name = name;
    }
  
    public String getName(){
      return name;
    }
  }
  </code></pre>
  
  <p>So I'm not using a setter because it should always stay the same. My colleague said that I can also do it this way:</p>
  
  <pre><code>public class ObjectIUse{
    public final String name;
  
    public ObjectIUse(String name){
      this.name = name;
    }
  }
  </code></pre>
  
  <p>Because now we don't need to have any getters or setters because it is public, however it can also never be changed because it is final. </p>
  
  <p>Which would be better? Or would it maybe be preferable to still make it private but also final? I mean all of the options work, obviously. I just want to know which is better and why.</p>