title: How the construction function runs when call static function in Java
body: <p>I want a class to check if an input is valid, and all the valid input is record in a text file.</p>
  
  <p>So in construction, it read in the text file and put all valid inputs into a HashSet. Then I have <code>static</code> function to receive an input and check if the input is in the HashSet.</p>
  
  <p>Code structure is like following:</p>
  
  <pre><code>public class Validator {
      HashSet validInputs;
  
      public Validator() {
          //read in
      }
  
      public static boolean validate(String in) {
          //check and return
      }
  }
  </code></pre>
  
  <p>Then in other class, I need to use <code>Validator</code> class to validate strings. Code is like:</p>
  
  <pre><code>...
  String a = XXX;
  boolean valid = Validator.validate(a);
  ...
  </code></pre>
  
  <p>I haven't tested the code, but I have two questions:</p>
  
  <ol>
  <li>Does it work? Is the valid input text file read in?</li>
  <li>When will the class read in the text file?</li>
  <li>Will <code>Validator</code> read the text file every time I call the function <code>validate()</code>?</li>
  </ol>