Monday, March 2nd, 2009
| 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();
|
Tags: Core Java, Null
Posted in General, Java | No Comments »