Tuesday, April 17, 2012

Java 7 new features

I have in love with Java decade ago,As time passed my love for Java decreased day by day due to lack of features as compared other programming languages.
But I have surprised to see the new features in Java 7 and I must say that Java came back to scene with with a right timing and graceful manner.
Few things I have observed in Java 7 are.
Numeric value with a underscore.
Now we can use underscore in numeric value such as
int amount=10_000;


More Stylish Exception Handling
 try {

methodThatThrowsThreeExceptions();

} catch (ExceptionOne | ExceptionTwo | ExceptionThree e) {

// log and deal with all Exceptions

}

String in switch block
         String id = t.getId();
switch (id) {
case ONE:
//code
break;
case TWO:
//code
break;
case THREE:
//code
break;
default:
break;
}

No comments:

Post a Comment