Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7673509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:31:40+00:00 2026-05-31T16:31:40+00:00

Nullable (C#) has a bit different meaning, but anyway both Option (Scala) and Nullable

  • 0

Nullable (C#) has a bit different meaning, but anyway both Option (Scala) and Nullable can be used to express the notion of “value or nothing”.

For example in case when you would like to find substring in a string — instead of obscure -1 as Int, it would be better to return Option[Int] (in Scala it would be None for nothing).

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

Please note, I am not asking how to write such class.

Update

As I wrote, Nullable has different meaning. Consider this:

Just imagine Map[K,V], and method get which semantics is to get value of key, if there is such key, or nothing when there is no such key.

You cannot use null for two reasons, you cannot use any concrete class for one reason. Option[V] is the way to go.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:31:41+00:00Added an answer on May 31, 2026 at 4:31 pm

    No. There is no such construct standard in Java.*

    There is Option in FunctionalJava or, as yshavit notes, Optional in Guava… Or, you could create your own type… but without proper language support… well, let’s just say I avoid Java 😉

    Happy coding.


    *I disagree that Integer or Double fulfill this role as they only wrap the fixed set of primitives and are not a generic container. They can be considered to cover the case of Nullable, simply due to Java’s fixed set of value types and C#’s limitation of Nullable (only works on ValueTypes), but they do not replace a real Option type.

    Do note however, that the Option from FJ or Guava still uses (it must, actually) the wrapper types (e.g. Integer) for handling primitives. Also note that Nullable in C# is not the same as Option in Scala due to the aforementioned restriction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Explain why a nullable int can't be assigned the value of null e.g int?
I have a non-nullable database column which has a default value set. When inserting
My objects often has nullable types properties that used as SQL commands parameters. I
Has any one used data validation on fields that are optional (nullable types)? I.e.
My Sql Server database has some nullable nvarchar fields, and no nvarchar fields containing
I have an SQL reporting server report which has 5 parameters which permit nullable
I have some hierarchical data - each entry has an id and a (nullable)
I have a nullable property, and I want to return a null value. How
I'm working with a bit of a legacy database, but here's the basic idea:
I have a table which has some nullable fields and when the user enters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.