title: Java: static field in abstract class
body: <p>I just start out with an example, that explains it best:</p>
  
  <pre><code>public abstract class A{
      static String str;
  }
  
  public class B extends A{
      public B(){
          str = "123";
      }
  }
  
  public class C extends A{
      public C(){
          str = "abc";
      }
  }
  
  public class Main{
  
      public static void main(String[] args){
          A b = new B();
          A c = new C();
          System.out.println("b.str = " + b.str);
          System.out.println("c.str = " + c.str);
      }
  }
  </code></pre>
  
  <p>This will print out:</p>
  
  <p>b.str = abc</p>
  
  <p>c.str = abc</p>
  
  <p>But I would like a solution where each subclass that instantiate the super class, has their <strong>own</strong> class variable, at the same time I want to be able to reference that class variable through the identifier, or a method call, defined in the abstract super class.</p>
  
  <p>So I would like the output to be: </p>
  
  <p>b.str = 123 </p>
  
  <p>c.str = abc</p>
  
  <p>Is that doable? </p>