Java Lambda Expression Functional Interfaces mark with @FunctionalInterface

Description

Java Lambda Expression Functional Interfaces mark with @FunctionalInterface

import java.util.function.Function;

public class Main {

   public static void main(String[] args) {
      ReverseType newText = (testText) -> {
         String tempStr = "";
         for (String part : testText.split(" ")) {
            tempStr += new StringBuilder(part).reverse().toString() + " ";
         }/*  w  ww  . j  ava  2s  .c  om*/
         return tempStr;
      };
      System.out.println(newText.reverse("HELLO WORLD"));
      
   }
}

@FunctionalInterface
interface ReverseType {

   String reverse(String text);
}



PreviousNext

Related