From 7f461fc7de7c71f6fadc8446af89802a9a7ca2fe Mon Sep 17 00:00:00 2001 From: wu <303054730@qq.com> Date: Thu, 24 Oct 2024 11:59:13 +0800 Subject: [PATCH] fix --- docs/chapter05.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/docs/chapter05.md b/docs/chapter05.md index 0cbf50c..a91e193 100644 --- a/docs/chapter05.md +++ b/docs/chapter05.md @@ -266,15 +266,11 @@ System.out.println(append.convert("Hello", "Lambda")); // 输出 "Hello, Lambda" ```java // 假设我们有一个简单的类 class Example { - private final int value; - - public Example(int value) { - this.value = value; + public Example() { } - - @Override - public String toString() { - return "Example{" + "value=" + value + '}'; + + public String doSomething() { + return "Example do something“; } } @@ -286,13 +282,11 @@ interface ExampleSupplier { public class Main { public static void main(String[] args) { // 使用lambda表达式和构造函数引用创建ExampleSupplier实例 - ExampleSupplier supplier = () -> new Example(42); + ExampleSupplier supplier = Example::new; // 使用ExampleSupplier实例来创建Example对象 Example example = supplier.get(); - - // 输出结果 - System.out.println(example); + example.doSomething(); } } ```