java streams in Java 7(Java 7 中的 Java 流)
问题描述
我的问题可能过于宽泛,答案可能很简单,但我必须问.
My question may be too broad and probably the answer is a simple NO, but I have to ask.
是否有 (Java 8) 流的任何等效实现* 在 Java 7 中?
Is there any equivalent implementation of (Java 8) streams* in Java 7?
我熟悉 (Java 8) 流,但我的项目要求是使用 Java 7.
I am familiar with (Java 8) streams but my project requirement is to use Java 7.
*不要与 inputStream 和 outputStream.
推荐答案
在官方API中,没有.
In the official API, no.
没有更多针对 Java 7 的公开更新.如果您是客户,您可能仍会获得较小的更新,但这不会(或非常非常不可能)用于向后移植 Stream API.
There is no more public updates for Java 7. If you're a customer, you might still get minor updates, but this not (or very very very unlikely) for back-porting the Stream API.
稍加挖掘,您可能会查看 StreamSupport.我从未测试过它,但显然它的目标是将 Stream API 向后移植到 Java 6/7,如果你想将它与 lambda 表达式结合起来,还有 retrolambda.
With a bit of digging you may look at StreamSupport. I've never tested it but apparently its goal is to backport the Stream API to Java 6/7 and if you want to combine it with lambda expressions there's also retrolambda.
Functional Java 可能很有趣.它与 Stream API 的意图并不完全相同,但如果您的目标是过滤/映射/等.一个列表/数组,它可能适合您的需求.对于示例:
Functional Java can be interesting. It's not exactly the same intent as the Stream API but if your goal is to filter/map/etc. a list/array it might suits your needs. For example:
final List<Integer> b = list(1, 2, 3).map(add.f(-1));
listShow(intShow).println(b); // [0, 1, 2]
最后,您可以查看 Scala 的 Stream API.由于 Scala 也在 JVM 上运行,因此您可以混合您的代码.也许这不是您想要的,但如果需要,值得一试.
Finally you can look into the Scala's Stream API. As Scala runs also on the JVM, you can mix your code. Maybe it's not exactly what you are looking for but it's worth a try if needed.
这篇关于Java 7 中的 Java 流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Java 7 中的 Java 流
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01