Java8新特性之lambda表达式
2021-07-12 16:05
标签:count() stl count oid 对象 pack ram junit setname Java8带来的新特性之一Lambda表达式,又称之为函数式编程,核心思想是将面向对象中的传递对象变为传递行为 expression = (variable) -> anction Java8新特性之lambda表达式 标签:count() stl count oid 对象 pack ram junit setname 原文地址:https://www.cnblogs.com/gosun/p/9545335.html简介
语法
eg: int sum = (x,y) ->x+y;
package com.jdk8;
public class Student {
private String name;
private String city;
private int age;
private String sex;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
}
package com.jdk8;
public interface TestInterface
package com.jdk8;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
public class TesFunction {
@Test
public void testLambda(){
//3.有参,有返回值
func((Integer x)->{
System.out.println("Hello,world"+x);
return true;
});
//
List