The original idea comes from groovy. It was proposed for Java 7 as part of Project Coin: https://wiki.openjdk.java.net/display/Coin/2009+Proposals+TOC (Elvis and Other Null-Safe Operators), but hasn't been accepted yet.

The related Elvis operator ?: was proposed to make x ?: y shorthand for x != null ? x : y, especially useful when x is a complex expression.

Answer from ataylor on Stack Overflow
🌐
InterviewBit
interviewbit.com › sql-interview-questions
90 + SQL Interview Questions CHEAT SHEET (2026) - InterviewBit
-- Expire existing record UPDATE customer_dim SET end_date = CURRENT_DATE, is_current = 'N' WHERE customer_id = 101 AND is_current = 'Y'; -- Insert new record INSERT INTO customer_dim ( customer_id, address, start_date, end_date, is_current ) VALUES ( 101, 'New Address', CURRENT_DATE, NULL, 'Y' ); This method ensures that historical data is preserved and reports can accurately reflect changes over time. SCD Type 2 is widely used when auditability and time-based analysis are required. MERGE (also known as UPSERT) is an operation that allows inserting new rows and updating existing rows in a single statement.
Published   January 25, 2026
🌐
Refactoring.Guru
refactoring.guru › home › design patterns › creational patterns
Singleton
January 1, 2025 - if (Database.instance == null) then Database.instance = new Database() return Database.instance // Finally, any singleton should define some business logic // which can be executed on its instance. public method query(sql) is // For instance, ...
Discussions

syntax - Java "?." operator for checking null - What is it? (Not Ternary!) - Stack Overflow
I was reading an InfoWorld article (link to Wayback machine since the excerpt was since removed), and came across this little tidbit: Take the latest version of Java, which tries to make null-poin... More on stackoverflow.com
🌐 stackoverflow.com
How hard would it be to add a safe call operator to the Java language?
Your example relies on an implicit null -> false. Usually null-safe operators return null if they short circuit. So your result would be Boolean instead of boolean and throw a NullPointerException. In addition to ?. Java would likely need a null fallback operator like ??: if (getLoggedInUser()?.isPowerUser() ?? false) {...} More on reddit.com
🌐 r/java
62
22
September 4, 2021
Doing null check on @Nullable functions via ternary operator still gets highlighted with "Potential null pointer access" problem
Chaining a function after a @Nullable-annotated function causes the @Nullable-annotated function to get highlighted with "Potential null pointer access" problem, even if a null check was ... More on github.com
🌐 github.com
4
October 10, 2022
Elvis and other null-safe operators in Java
+1 from me. Elvis operator is much needed More on reddit.com
🌐 r/java
72
47
December 15, 2017
🌐
Baeldung
baeldung.com › home › java › java numbers › check if an integer value is null or zero in java
Check if an Integer Value Is Null or Zero in Java | Baeldung
January 8, 2024 - In this quick tutorial, we’ll ... if each approach works as expected. So, next, let’s see them in action. Using the logical OR operator ......
🌐
Coderanch
coderanch.com › t › 202493 › java › Null-check
Null check (Performance forum at Coderanch)
In this case, the above if statement always evaluates to false. To avoid this, some people use if (NULL == var) because if you accidentally type if (NULL = var) it will cause a compiler error. I think this convention is just a hold-over from C++ and has no significant performance ramifications ...
🌐
Medium
medium.com › @vikas.taank_40391 › java-clean-and-better-code-null-checks-76f6c60e11b0
Java Clean and Better Code: Null Checks | by Vikas Taank | Medium
February 15, 2025 - Instead of returning Null , return optional. For example. import java.util.Optional; public class UserService { public Optional<User> findUserById(Long id) { return Optional.ofNullable(userRepository.findById(id)); } }
🌐
Site Title
ftp.pink-ribbon.be › home › ultimate guide to checking null values in java: essential tips for clean code
Ultimate Guide to Checking Null Values in Java: Essential Tips for Clean Code
February 3, 2025 - The inequality operator is a useful tool for checking for null values in Java. It is simple to use and efficient, and it is supported by all versions of Java. However, it is important to remember that the inequality operator can only be used ...
🌐
Oracle
docs.oracle.com › cd › E19316-01 › 819-3669 › bnbvr › index.html
NULL Values (The Java EE 5 Tutorial)
The IS NULL test converts a NULL persistent field or a single-valued relationship field to TRUE. The IS NOT NULL test converts them to FALSE. Boolean operators and conditional tests use the three-valued logic defined by Table 27–6 and Table 27–7.
🌐
LabEx
labex.io › tutorials › java-how-to-check-if-a-boolean-object-is-null-in-java-559932
How to Check If a Boolean Object Is Null in Java | LabEx
We demonstrated the correct way to check for null using the equality operator (== null) and also showed how to safely check the boolean value using the equals() method of Boolean.TRUE and Boolean.FALSE.
Find elsewhere
🌐
Kotlin
kotlinlang.org › docs › java-to-kotlin-nullability-guide.html
Nullability in Java and Kotlin | Kotlin Documentation
To make it return null, you can use the boxed type Integer. However, it's more resource-efficient to make such functions return a negative value and then check the value – you would do the check anyway, but no additional boxing is performed this way. When migrating Java code to Kotlin, you may want to initially use the regular cast operator as with a nullable type to preserve the original semantics of your code.
🌐
Baeldung
baeldung.com › home › java › avoid check for null statement in java
Avoid Check for Null Statement in Java | Baeldung
1 week ago - Without flatMap, the result would be Optional<Optional<String>>. The flatMap operation is only performed when the Optional is not empty. Lombok is a great library that reduces the amount of boilerplate code in our projects. It comes with a set of annotations that take the place of common parts of code we often write ourselves in Java applications, such as getters, setters and toString(), to name a few.
🌐
Reddit
reddit.com › r/java › how hard would it be to add a safe call operator to the java language?
r/java on Reddit: How hard would it be to add a safe call operator to the Java language?
September 4, 2021 -

Checking for null is quite verbose in Java. The current best practice is to either use Nullability annotations or Optional<T>. Personally, I'm in the annotations camp. Yes, optional is very useful in streams but I don't like the cognitive and runtime overhead it implies anywhere else.

My dream would be if one day nullability would be added to the type system. Obviously, that's a lot of work. But wouldn't be a pragmatic first step, to reduce just the boilerplate of null checks with a safe call operator? The compiler could surely rewrite this code:

if (getLoggedInUser()?.isPowerUser()) {
}

To this:

if (getLoggedInUser() != null && getLoggedInUser().isPowerUser()) {
}

To avoid an unexpected double method invocation, it could assign to ad hoc created temp variables:

User generatedSafeCall1;
if ((generatedSafeCall1 = getLoggedInUser()) != null && generatedSafeCall1.isPowerUser()) {
}

I believe this would end a lot of complaints about null handling in Java. Since only new code would use the ?. operator, backwards compatibility shouldn't be an issue either. Are there any downsides that I'm missing?

🌐
Jenkov
jenkov.com › tutorials › java › ternary-operator.html
Java Ternary Operator
May 12, 2024 - You can use the Java ternary operator as a shorthand for null checks before calling a method on an object.
🌐
GitHub
github.com › redhat-developer › vscode-java › issues › 2727
Doing null check on @Nullable functions via ternary operator still gets highlighted with "Potential null pointer access" problem · Issue #2727 · redhat-developer/vscode-java
October 10, 2022 - getSomethingNullable() is annotated with @Nullable and will be highlighted despite having a prior null check. This does not occur when doing if-else null check, only when using a ternary operator.
Published   Oct 10, 2022
🌐
Belief Driven Design
belief-driven-design.com › better-null-handling-with-java-optionals-da974529bae
Better Null-Handling With Java Optionals | belief driven design
December 17, 2019 - This can be great, you don’t have to null-check everything. But it’s also bad because you might not realize that a message wasn’t answered. With the release of Java 8, a straightforward way of handling null references was provided in the form of a new class: java.util.Optional<T>.
🌐
Kotlin
kotlinlang.org › docs › null-safety.html
Null safety | Kotlin Documentation
August 28, 2025 - Usage of the not-null assertion operator !!. Data inconsistency during initialization, such as when: An uninitialized this available in a constructor is used somewhere else (a "leaking this "). A superclass constructor calling an open member whose implementation in the derived class uses an uninitialized state. ... Attempts to access a member of a null reference of a platform type. Nullability issues with generic types. For example, a piece of Java ...
🌐
Oracle
oracle.com › java › technical details
Tired of Null Pointer Exceptions? Consider Using Java SE 8's Optional!
Scala has a similar construct called Option[T] to encapsulate the presence or absence of a value of type T. You then have to explicitly check whether a value is present or not using operations available on the Option type, which enforces the idea of "null checking." You can no longer "forget to do it" because it is enforced by the type system. OK, we diverged a bit and all this sounds fairly abstract. You might now wonder, "so, what about Java SE 8?"
🌐
Quora
quora.com › Which-is-more-efficient-for-checking-null-values-ternary-operators-or-if-statements
Which is more efficient for checking null values: ternary operators or if statements? - Quora
But there is a method that is slightly more efficient. The and and or operators generally do the job, given proper shortcut semantics, before you get to needing the ternary operator. You can almost always say [code ](this ...
🌐
DEV Community
dev.to › scottshipp › better-null-checking-in-java-ngk
Better Null-Checking in Java - DEV Community
January 11, 2019 - Java doesn’t allow operator creation, so we can’t imitate this behavior exactly, but I have used some of the functional features found in Java 8, such as method references, to create similar functionality. Take a look. As a motivating example, finding a user’s zip code in their account might look similar to this in standard Java: That’s three null checks in the space of ten lines.
🌐
LabEx
labex.io › tutorials › java-how-to-check-if-an-object-is-null-in-java-560011
How to Check If an Object Is Null in Java | LabEx
We use an if statement with the equality operator (==) to check if message is null. If message == null is true, we print "The message is null.". If it's false, we print the message itself.