title: Java: assign final variable in subclass before super
body: <p>I have a class A which contains a final int, valA.</p>
  
  <p>I have a subclass B which contains a large final object, objB.</p>
  
  <p>The value of valA depends on objB which is passed in with B's constuctor.</p>
  
  <p>How can I create an instance of B?</p>
  
  <p>I've included minimal code for what I'm trying to do.</p>
  
  <pre><code>public class Test {
      public static void main(String[] args){
          System.out.println(new B(3).valA);
      }
      static class A{
          final int valA;
          A(int valA) {
              this.valA = valA;
          }
      }
      static class B extends A{
          final Object objB;
          B(int initVal) {
              this.objB = someMethod(initVal);
              super(objB.hashCode()+1);
          }
      }
      Object someMethod(int initVal){
          // pretend there's some super complicated logic that returns a large object
          return new Object();
      }
  }
  </code></pre>