Resources

“Functional”

It allows code to be considered “declarative” over “imperative”.

Functional Interface (@FunctionalInterface)

@FunctionalInterface
public interface Profile {

    // Abstract method to get the profile information
    String getProfileInfo();

    // Default method to display a default message
    default void displayDefaultMessage() {
        System.out.println("This is a default message for profiles.");
    }

    // Static method to create a default profile
    static Profile createDefaultProfile() {
        return () -> "Default Profile";
    }
}

Lambdas Expressions/Anonymous Function (JDK 8)

Old style

new Thread(new Runnable {
  public void run() {
    fetchProfiles();
  }
}).start();

New style

new Thread(() -> fetchProfiles()).start();