title: How to create an "abstract field"?
body: <p>I know abstract fields do not exist in java. I also read <a href="https://stackoverflow.com/questions/2211002/why-not-abstract-fields">this question</a> but the solutions proposed won't solve my problem. Maybe there is no solution, but it's worth asking :)</p>
  
  <h2>Problem</h2>
  
  <p>I have an abstract class that does an operation <strong>in the constructor</strong> depending on the value of one of its fields.
  The problem is that the <strong>value of this field will change depending on the subclass</strong>.
  How can I do so that the operation is done on the value of the field redefined by the subclass ?</p>
  
  <p>If I just "override" the field in the subclass the operation is done on the value of the field in the abstract class.</p>
  
  <p>I'm open to any solution that would <strong>ensure that the operation will be done during the instantiation of the subclass</strong> (ie putting the operation in a method called by each subclass in the constructor is not a valid solution, because someone might extend the abstract class and forget to call the method).</p>
  
  <p>Also, I don't want to give the value of the field as an argument of the constructor.</p>
  
  <p>Is there any solution to do that, or should I just change my design ?</p>
  
  <hr>
  
  <h2>Edit:</h2>
  
  <p>My subclasses are actually some tools used by my main program, so the constructor has to be public and take exactly the arguments with which they will be called:</p>
  
  <pre><code>tools[0]=new Hand(this);
  tools[1]=new Pencil(this);
  tools[2]=new AddObject(this);
  </code></pre>
  
  <p>(the subclasses are Hand, Pencil and AddObject that all extend the abstract class Tool)</p>
  
  <p>That's why I don't want to change the constructor.</p>
  
  <p>The solution I'm about to use is to slightly change the above code to:</p>
  
  <pre><code>tools[0]=new Hand(this);
  tools[0].init();
  tools[1]=new Pencil(this);
  tools[1].init();
  tools[2]=new AddObject(this);
  tools[2].init();
  </code></pre>
  
  <p>and use an abstract getter to acces the field.</p>