Stephan van Hulst wrote:You mean int?, not ?int.
.
Only write NULL when writing C please. It's called null in Java®.Monica Shiralkar wrote:Thanks. For instance, in case of Java optionalInt was introduced in java 1.8 to pass or return an int optionally or NULL.
There wasn't a “standard way” to do that before.How was the same thing being done before that ?
Monica Shiralkar wrote:Thanks. For instance, in case of Java optionalInt was introduced in java 1.8 to pass or return an int optionally or NULL.How was the same thing being done before that ?
Monica Shiralkar wrote:Thanks. Is returning an integer or a NAN be an example use case whether either a number is returns or null in case of NAN ?
Stephan van Hulst wrote:It makes it explicit that the function might not have an answer. It forces the client to check that a result is present, because the first code snippet will cause a NullPointerException if the client forgets to check the result.
The wrapper classes have been there from the very beginning.Monica Shiralkar wrote:. . . before Java 1.5 when . . . .
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |