Can we use Optionals in Android programming?

前端 未结 3 655
-上瘾入骨i
-上瘾入骨i 2021-01-12 01:02

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

But does the Dalvik machine for the latest versions of Android

3条回答
  •  死守一世寂寞
    2021-01-12 01:38

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

    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)

提交回复
热议问题