title: incompatible types: Object is not a functional interface netbeans-11 java
body: <p>I'm quite new to lambda expression of Java 8</p>
  
  <p>I tried the following and get compile error</p>
  
  <pre><code>class Test{
      static interface MySupplier {
  
          Object supply();
      }
  
      public static void main(String[] args) {
          Object v = value();
          if (v instanceof MySupplier) {
              v = ((MySupplier) v).supply();
          }
          System.out.println(v);
      }
  
      static Object value() {
  //        return () -&gt; "this line will NOT get compiled."; //Error: incompatible types: Object is not a functional interface ???
  //        return (Object)(() -&gt; "this line will NOT get compiled, too."); //Error: incompatible types: Object is not a functional interface ???
          return new MySupplier() {
  
              public Object supply() {
                  return "using inner class will work but lambda expression it not";
              }
          };
  
      }
  }
  </code></pre>
  
  <p>my question is "could it be possible to use lambda expression as normal object. I want to do some thing like</p>
  
  <pre><code>    static Object value(Object v) {
          if (v instanceof MySupplier) {
              return ((MySupplier) v).supply();
          }
          return v;
      }
  
      public static void main(String[] args) {
  //        if some case
          Object v1 = value("value 1");
          // else if some other case
          Object v1 = value(() -&gt; { 
              //do some stuff
              return "value 2";
          });
      }
  </code></pre>
  
  <p>I did a lot of search but no luck. Is there any workaround? 
  thanks in advance!</p>
  
  <hr>
  
  <p>update: after having better understanding about lambda expression, the problem is how to let the compiler know the target-type of lambda expression to compile to. 
  so the answer from ernest_k could be improve as</p>
  
  <pre><code>return (MySupplier) () -&gt; "this line will work";
  </code></pre>