functional programming in Java

前端 未结 5 1021
滥情空心
滥情空心 2021-01-17 13:58

how can you emulate functional programming in java, specifically, doing things like map a function to a collection of items?

map(func, new String[]{\"a\",\"         


        
5条回答
  •  别那么骄傲
    2021-01-17 14:58

    Just wrap the function you want to apply on the list with a class or an interface.

    public interface Func {
      Object f(Object input);
    }
    
    public void map (Func func, Object[] arr) {
      for(int i=0;i

提交回复
热议问题