Function Object in Java

后端 未结 5 763
醉话见心
醉话见心 2021-02-03 11:32

I wanna implement a javascript like method in java , is this possible ?

Say , I have a Person class :

public class Person {
 private String name ;
 priva         


        
5条回答
  •  梦如初夏
    2021-02-03 12:16

    Take a look at the lambdaj project. Here is an example from the project home page:

    List personInFamily = asList(new Person("Domenico"), new Person("Mario"), new Person("Irma"));
    forEach(personInFamily).setLastName("Fusco");
    

提交回复
热议问题