Is it possible to use the Java 8 Stream API on Android API < 24?

后端 未结 6 2066
南笙
南笙 2020-11-28 06:15

I\'ve read this post here. But still I cannot run code containing Java 8 Stream API features like the following on minSdkVersion < 24.

List new         


        
6条回答
  •  广开言路
    2020-11-28 06:54

    Another solution I like to use is to statically use Kotlin's extensions over Collections from Java code, if the project supports both of course:

    List newCars = CollectionsKt.filter(cars, s -> s.getColor().equals("red"));
    

    Same for .map, .reduce, .first, ...etc

提交回复
热议问题