Java 7中的java流 [英] java streams in Java 7

查看:81
本文介绍了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中的href =https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html>流 *?

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.

功能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流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆