Lambda expressions can simplify your code, making it easier to read and write functional interfaces.
Source Code
interface StringFunction {
String run(String str);
}
public class Main {
public static void main(String[] args) {
StringFunction exclaim = (s) -> s + "!";
StringFunction ask = (s) -> s + "?";
System.out.println(exclaim.run("Hello"));
System.out.println(ask.run("Hello"));
}
}