title: How to set inherited variable in java?
body: <pre><code>public class Atribut {
  int classid;
  
  @Override public String toString() {
  return Integer.toString(classid);
  
  
  }
  
  }
  </code></pre>
  
  <p>I have made this class which overrides method toString(). I plan on making many subclasses with different classid. The problem is I dont know how to set the variable classid to work in toString method.</p>
  
  <pre><code>public class cas extends Atribut{
  int classid=2;
  
  
  }
  </code></pre>
  
  <p>The problem is if I make an cas object and toString method it returns "0" not "2".??</p>