title: Treating class as a constant
body: <pre><code>abstract class Coin{
      String name;
      String currency;
  
  
      class EUR extends Coin{
          EUR() {
          super("EUR", "€");
          }
  
      }
      class USD extends Coin{
          USD() {
          super("USD", "$");
          }
  
      }
  
      private Coin (String name, String currency){
      this.name = name
      this.currency = currency}
      }
  
  class Person{
      ///variables
      Coin coin;
  
      Person(//Variables, Coin coin){
          //Other assignments
          this.coin = coin
      }
  
  }
  </code></pre>
  
  <p>Basically i would like to initialize a Person passing EUR as Coin, without creating a new EUR.
  Something like</p>
  
  <pre><code>static final EUR euro = EUR
  </code></pre>
  
  <p>and then:</p>
  
  <pre><code>Person person = new Person(... , euro);
  </code></pre>
  
  <p>I do not need millions of instances of EUR so i don't want to create each time a new EUR</p>
  
  <p>I know i can make something like this using constant Strings, but i actually want to pass a Coin object</p>
  
  <p>I also tried initializing EUR inside Coin class like this</p>
  
  <pre><code>static EUR euro = new EUR();
  </code></pre>
  
  <p>But IDE is warning me this could cause thread deadlock</p>