title: Best way to Make Public Variables(JAVA)
body: <p>I have a question what is the most correct way for making variables that are accesible in all classes?? </p>
  
  <p>I know to ways, one harder than the other.</p>
  
  <p>First one:</p>
  
  <pre><code>public class x {
  
  public String z:
  
  }
  </code></pre>
  
  <p>And second one is making the variables in one class, like locals and with setters and getters make something like this (I dont know to well this one). And in the class you want to use it you only use the constructor of the class</p>
  
  <pre><code>public class x {
  
  public x{
  String a:
  }
  set a (String){
  this.a = a
  
  }
  
  }
  </code></pre>
  
  <p>Or something like that. (I hope you understand the way i Reffer.)</p>
  
  <p>I want to know what is the most correct, in terms of coding quality, and what do professional programmers use.</p>