我经常使用javascript,找到 underscorejs 对于操作数据集非常方便,例如数组或对象。
我是 Java 的新手,想知道是否有类似的 Java 库?
最佳答案
有图书馆underscore-java . Live example
import com.github.underscore.U;
public class Main {
public static void main(String args[]) {
String[] words = {"Gallinule", "Escambio", "Aciform", "Entortilation", "Extensibility"};
Number sum = U.chain(words)
.filter(w -> w.startsWith("E"))
.map(w -> w.length())
.sum().item();
System.out.println("Sum of letters in words starting with E... " + sum);
}
}
// Sum of letters in words starting with E... 34
关于java - 是否有用于 java 的 underscore.js 库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27772432/