title: How to define Global variable outside class?
body: <p>I'd like to define variable which can share values to classes.</p>
  
  <p>so I tried as following.</p>
  
  <p>But It occured error.</p>
  
  <p>How to share a value to classes?</p>
  
  <pre><code>package com.company;
  
      /////// Error occurred ///////
      int sharedValue = 100;   // &lt;- How to share to classes?
      //////////////////////////////
  
      public class Main {
  
          public static void main(String[] args) {
              sharedValue += 10;
  
              GlobalTest globalTest = new GlobalTest();
              globalTest.printGlobalValue();
          }
      }
  
      class GlobalTest {
          void printGlobalValue() {
              System.out.println(sharedValue);
          }
      } 
  </code></pre>