title: How to initialize a value when creating an object in a static block
body: <p>When creating the Racing class in ApplicationTest, I want to hand over the FixNumberBehavior class to the argument.</p>
  <p>As shown below, to pass the argument to initialize FixNumberBehavior, but cannot pass the class field value to the static block.</p>
  <p>The error message is as follows.</p>
  <p><code>Variable 'isMove' might not have been initialized</code></p>
  <p>FixNumberBehavior.java</p>
  <pre><code>public class FixNumberBehavior implements CarMoveBehavior {
  
    private final boolean isMove;
    private static FixNumberBehavior fixNumberBehavior;
  
    static {
        fixNumberBehavior = new FixNumberBehavior(); //error
    }
  
    public FixNumberBehavior(final boolean isMove) {
        this.isMove = isMove;
    }
  
    @Override
    public boolean moveBehavior() {
       return isMove;
    }
  }
  </code></pre>
  <p>Racing.java</p>
  <pre><code>public class Racing {
  
  private List&lt;Car&gt; cars;
  private CarMoveBehavior carMoveBehavior;
  
  public Racing(List&lt;Car&gt; cars, final CarMoveBehavior carMoveBehavior) {
      this.cars = cars;
      this.carMoveBehavior = carMoveBehavior;
  }
  
  public List&lt;Car&gt; getCars() {
      return cars;
  }
  
  public void drive() {
      cars.stream()
          .forEach(car -&gt; racingCondition(car));
  }
  
  private void racingCondition(Car car) {
      if (carMoveBehavior.moveBehavior()) {
          car.moveForward();
       }
    }
  }
  </code></pre>
  <p>ApplicationTest</p>
  <pre><code> @ParameterizedTest
      @CsvSource({&quot;a,aa,aaa&quot;})
      void fixRandomNumberTest(String one, String two, String three) {
          final List&lt;Car&gt; cars = Arrays.asList(new Car(one), new Car(two), new Car(three));
          Racing racing = new Racing(cars, new FixNumberBehavior(true));
          racing.drive();
          racing.drive();
          assertAll(
              () -&gt; assertThat(cars.get(0).getStep()).isEqualTo(2),
              () -&gt; assertThat(cars.get(1).getStep()).isEqualTo(2),
              () -&gt; assertThat(cars.get(2).getStep()).isEqualTo(2)
          );
      }
  </code></pre>
  <p>How can I initialize an object in the static block?</p>