title: Changing a java object outside its class
body: <p>Here's my question, how can I change an object outside of it's class, so that it maintains the changes made in the outside class?</p>
  
  <p>Here's an example of the code:</p>
  
  <p><strong>Main class:</strong></p>
  
  <pre><code>    public class Main {
  
          public static void main(String[] args)
          {
              Variable var = new Variable(1,2,3);
              Change.changeVar(var);
              System.out.println("" + var.geta() + "" + var.getb() + "" + var.getc());
          }
      }
  </code></pre>
  
  <p><strong>Variable class:</strong></p>
  
  <pre><code>public class Variable {
  
  private int a;
  private int b;
  private int c;
  
  public Variable(int a, int b, int c)
  {
      this.a = a;
      this.b = b;
      this.c = c;
  }
  
  public int geta()
  {
      return this.a;
  }
  
  public int getb()
  {
      return this.b;
  }
  
  public int getc()
  {
      return this.c;
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>Change class:</strong></p>
  
  <pre><code>public class Change {
  
  public static void changeVar(Variable var)
  {
      Variable var2 = new Variable(4,5,6);
      var = var2;
  }
  </code></pre>
  
  <p>}</p>