Null Check in Java 7.0
March 2nd, 2009
3 comments
| Null check is becoming easier in Java7.0. I hope most of you aware of this. I was reading one of the java blog and found the following is interesting there.Earlier Version of Java |
Car car = ...Integer tilt = null;
if(car != null) {
Sunroof sunroof = car.getSunroof();
if(sunroof != null) {
tilt = sunroof.getTilt();
}
}
|
| In Java7.0, the above statement can be written as. |
Integer tilt = car?.getSunroof()?.getTilt(); |












