我们可以在Android编程中使用Optionals吗? [英] Can we use Optionals in Android programming?

查看:456
本文介绍了我们可以在Android编程中使用Optionals吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读Java 8中的Optional类型。我想在我的一些Android代码中实现。

I have been reading about the Optional type in Java 8. I want to implement in some of my Android code.

但Dalvik机器是否为最新版本Android(5.1和6)在Java 8中实现了什么?

But does the Dalvik machine for the latest versions of Android (5.1 and 6) implement everything in Java 8?

我仍在运行Java 7,我的计算机上安装了Eclipse和Android Studio。

I'm still running Java 7 with the Eclipse and Android Studio installed on my computers.

推荐答案

是的。但仅限于API级别24 / Nougat(在当前撰写时间)。

Yes. But only on API level 24 / Nougat (in current time of writing).

对于前Nougat,您可以选择使用这些库:

For pre-Nougat, you may opt to these libraries:

  • Options (https://github.com/tomaszpolanski/Options)
  • Arrow (https://github.com/android10/arrow)
  • StreamSupport (https://github.com/streamsupport/streamsupport)
  • Optional (https://github.com/MrHadiSatrio/Optional)
  • Guava (https://github.com/google/guava)

这篇关于我们可以在Android编程中使用Optionals吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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