Java "?" Operator for checking null - What is it? (Not Ternary!)

This syntax does not exist in Java, nor is it slated to be included in any of the upcoming versions that I know of.


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.

Tags:

Java

Syntax

Null