title: Is it possible to move variable's values from one class to another class without inheritance in java?
body: <p>I have learnt how to call methods and even variables between two classes. I wanted to know if you can move values from one class to another without using inheritance. Here is an example:</p>
  
  <ol>
  <li>I create two classes: class1 and class2.</li>
  <li>I enter a variable with a value in class1.</li>
  <li>Move a variable's value to class2.</li>
  <li>Let the value to be tested by if statements in class2.</li>
  <li>The output in class 2 can be moved to class1 or method with the output in class2 can be called within class1.</li>
  </ol>
  
  <p>This is not a real program architecture though, it's just for my learning purposes. Thank you.
  Update:
  I was asked to post some code of what I have done to show the idea above.
  Here is one class:</p>
  
  <pre><code>class MainClass
  {
  public static void main(String[] args)
  {
      System.out.println("You have entered: " + args[0]);
      static int num = Integer.parseInt(args[0]);
      SubClass.calc(); //I believe I override it by passing value to a method within SubClass
  }
  
  }
  </code></pre>
  
  <p>Here is the second class:</p>
  
  <pre><code>class SubClass
  {
      public static void calc()
  {
      System.out.println("This is the output" + MainClass.num);
  }
  }
  </code></pre>
  
  <p>I tried to move my value in args[0] from MainClass to SubClass, but I get an error when I try to cast it from string to int data type:</p>
  
  <pre><code>pavel@pavel-OptiPlex-GX270:~/myjava$ javac MainClass.java
  MainClass.java:9: error: cannot find symbol
  static int num = Integer.parseInt(args[0]);
                                    ^
  symbol:   variable args
  location: class MainClass
  1 error
  </code></pre>
  
  <p>Is there anything I can do to solve the problem?</p>