title: Using init function after constructor vs initializing in constructor - JAVA
body: <p>What is the difference between</p>
  
  <pre><code>public UserBean() {
          // create the session state
          state = new BigInteger(64, new SecureRandom()).toString(32);
  
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public UserBean() {
          init();
  }
  
  @PostConstruct
      public void init() {
          // create the session state
          state = new BigInteger(64, new SecureRandom()).toString(32);            
      }
  </code></pre>
  
  <p>where state is one of the many attributes of the class.</p>