Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8217443

Lambda overloading instead of @FuncationalInterface

XMLWordPrintable

    • x86_64
    • generic

      A DESCRIPTION OF THE PROBLEM :
      I see Lambda only work with @FunctionalInterface. As I understand it is because Lambda expression match with the abstract method if there is more than one method then it will confuse the compiler to which one run. But suppose if you have two or more functions with different parameters or parameter type or return type then it can work same as function overloading.

      Example:

      public interface Foo{
          void show(String message);
          void count(int number);
      }

      // Lambda Expression
      x -> "Some Message" // Call the show method from Foo interface
      x -> 5 // Call the count method from Foo interface

      Why this is not possible?


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: