Is there a standard option or nullable class in Java?

Nullable (c#) has some different meanings, but in any case, option (Scala) and nullable can be used to express the concept of "valuable or worthless"

For example, if you want to find a substring in a string - instead of intcure - 1 as int, it's best to return option [int] (in Scala, it will be none)

Is there such a class in standard Java? If so, what is it?

Please note that I am not asking about such courses

to update

As I wrote, nullable has different meanings Think about it:

Imagine which semantics of map [K, v] and method is the value of obtaining the key. If there is such a key, or there is no such key at all

You can't use null for two reasons. You can't use any specific class for one reason Option [v] is the way to go

Solution

No, There is no such construction standard in Java*

There are 7000 or, as yshavit said, optional in guava... Or, you can create your own type... But there is no appropriate language support... Well, I just want to say that I avoid using Java

The above is a collection compiled by programming house for you. Is there a standard option or nullable class in Java? I hope this article can help you solve whether there is a standard option or nullable class in Java? Program development problems encountered.

If you think the content of the programming home website is good, you are welcome to recommend the programming home website to programmers and friends.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>