如代码 主要优化日志性能
import java.io.*;
public class FuXi2 {
public static void main(String[] args) throws IOException {
// demo02();
//创建多个日志字符串
String w1 = "Hello";
String w2 = "World";
String w3 = "Java";
demo01(() -> w1+w2+w3,2);//lambda表达式最简写 使用条件:参数类型是函数式接口
// 其中() -> w1+w2+w3是lambda表达式简写重写了里面的抽象方法 代表返回这个拼接字符串
// 这样写的好处 最大化优化性能 不用每次先拼接字符串再进行判断 int变量不正确时拼接字符串浪费内存
}
private static void demo01(Jiekou a, int a2) {//创建日志判断规则 int变量为2发送报告
if (a2 == 2) {
System.out.println(a.method());
}
}