mirror of
https://gitee.com/many2many/java-web.git
synced 2025-01-11 14:40:55 +08:00
fix
This commit is contained in:
parent
9558107356
commit
7f461fc7de
@ -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();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user