title: Java - call a variable from another class
body: <p>Within my main method I'm trying to understand how to call up a variable from a different class.</p>
  
  <p>I've attempted to break it down to the most simple solution possible just so I can get my head around the logic involved.</p>
  
  <p>I have two classes within my package "var":</p>
  
  <p>Class 1 - Source.java</p>
  
  <pre><code>package var;
  
  public class Source {
  
      int source1;
  
      class setSource{
  
      int source1 = 5;
  
  }
  }
  </code></pre>
  
  <p>Class 2 - Var.java</p>
  
  <pre><code>package var;
  
  public class Var {
  
      public static void main(String[] args) {
  
          int Var;
  
          Var = Source.setSource();
  
      }
  
  }
  </code></pre>
  
  <p>First time post here but I've spent 4 days and almost all my spare time trying to figure this out, please be gentle I'm dedicated but extremely newbie right now.  Thanks in advance, I hope I've submitted this correctly.</p>