title: Difference between dynamic boolean expression variable and boolean function
body: <p>I came across this doubt: what is the difference between these two ways of getting a boolean value? The end result is the same, but what are the advantages and disadvantages of using one or the other? What's the most used approach? What is the best practice of this coding style?<br>
  <strong>Dynamic boolean expression variable</strong>  </p>
  
  <pre><code>...
  public class MainActivity extends AppCompatActivity {
      private boolean isVersionM = Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M;
      ....
      private void onCreate(Bundle savedInstanceState) {
          ....
          if (isVersionM) {
              ...
          }
          else {
              ...
          }
          ...
      }
      ....
  }
  </code></pre>
  
  <p><strong>Boolean function</strong></p>
  
  <pre><code>...
  public class MainActivity extends AppCompatActivity {
      ....
      private void onCreate(Bundle savedInstanceState) {
          ....
          if (isVersionM()) {
              ...
          }
          else {
              ...
          }
          ...
      }
      ...
      private boolean isVersionM() {
          return Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M;
      }
      ...
  }
  </code></pre>