title: Using Scala from Java: passing functions as parameters
body: <p>Consider the following Scala code:</p>
  
  <pre><code>package scala_java
  object MyScala {
    def setFunc(func: Int =&gt; String) {
      func(10)
    }
  }
  </code></pre>
  
  <p>Now in Java, I would have liked to use <code>MyScala</code> as:</p>
  
  <pre><code>package scala_java;
  public class MyJava {
      public static void main(String [] args) {
          MyScala.setFunc(myFunc);  // This line gives an error
      }
      public static String myFunc(int someInt) {
          return String.valueOf(someInt);
      }
  }
  </code></pre>
  
  <p>However, the above does not work (as expected since Java does not allow functional programming). What is the easiest workaround to pass a function in Java? I would like a generic solution that works with functions having arbitrary number of parameters. </p>
  
  <p>EDIT: Does Java 8 have any better syntax than the classic solutions discussed below? </p>