Java初心者です。
関数型インターフェースの使いどころについて教えてください。
関数型インターフェースの使用例としてよく次のようなコードを見かけます。
public class FunctionTest { public static void main(String[] args) { Function<String, String> function = x -> x + " World!"; String result = function .apply("Hello"); System.out.println(result); // Hello World! } }
関数型インターフェースを使用しなくても同じことができます。
public class FunctionTest { public static void main(String[] args) { String result = method1("Hello"); System.out.println(result); // Hello World! } private String method1(String x) { return x + " World!"; } }
関数型インターフェースは何のために使用するのでしょうか?

回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2024/07/17 11:21
2024/07/17 12:09