title: Java boolean equations as parametar of function
body: <p>Lets take a look at my program. That have some imaginary .txt file with car models.</p>
  
  <pre><code>public class Car {
      private String model;
  
      public String getModel() {
          return this.model;
      }
  }
  
  public class Main {
      public static void Main(String[] args) {
          ArrayList&lt;Car&gt; cars = loadCars(path); //imaginary func and file
          String someModel = generateSomeModel(); //imaginart func
  
          for (Car c : cars) 
              if (c.getModel.equals(someModel))
                  System.out.println("Hit!");
  
          for (Car c : cars) 
              if (!c.getModel.equals(someModel))
                  System.out.println("Hit!");
  
      }
  }
  </code></pre>
  
  <p>Lets suppose that I have to go through my cars list a 100 times and compare them in if statement for some different attributes every time, that means I  will have to write 100 different for loops that will be 90% same. Is there a way to write a function that will take as a parametar Boolean equation? Something like this.</p>
  
  <pre><code>public static void printCars(Boolean equation) {
      for (Car c : cars) 
          if (Boolean equation)
              System.out.println("Hit!");
  }
  </code></pre>