title: Dummy variable to handle return of a void method in Java?
body: <p>When I need to run an expression (an external method for example) outside a method in current object I declare a field variable for that object class and assign return value of that expression to that variable. Like below,</p>
  
  <pre><code>class{
  variabletype a=expression();
    public int method(){
    -----}
  }
  </code></pre>
  
  <p>Here expression() is evaluated before start of any methods of the class. It works perfectly unless return type of expression() is void. What I am looking for is a way to achieve the same even when expression() doesn't return anything. More specifically I need a type of dummy variable to do the same thing as done in line 2 of the code shown above even when expression() returns nothing. Note: I have no access to the constructor of the class.</p>