title: Java - Returning function with parameters
body: <p>I just started to learn about the lambda functions in Java. And wondering if this is the proper way of create a "adder".</p>
  
  <pre><code>public class Application {
      public static void main(String[] args){
          Function&lt;Integer, Integer&gt; fiveAdder = adder(5);
          System.out.println(fiveAdder.apply(1)); //6
          System.out.println(fiveAdder.apply(2)); //7
          Function&lt;Integer, Integer&gt; tenAdder = adder(10);
          System.out.println(tenAdder.apply(1)); //11
          System.out.println(tenAdder.apply(2)); //12
          System.out.println(fiveAdder.apply(1)); //6
          System.out.println(fiveAdder.apply(2)); //7
      }
  
      public static Function&lt;Integer, Integer&gt; adder(Integer inc){
          return num -&gt; num + inc;
      }
  }
  </code></pre>
  
  <p>The code is running fine. But I am not sure if that is the proper way of doing it, or if there is a better way. Like the function part <code>num -&gt; num + inc</code> is using <code>inc</code> but not some final/static field. (Plus IntelliJ is high-lighting the <code>inc</code> for me that makes me suspicious...)</p>
  
  <p>Thank you for any help.</p>