| New Java 5 features |
| Tuesday, 24 March 2009 | |
|
Java 5 encompases the first set of new language features since Java 2. These features are:- Autoboxing - This allows you to use primitives and objects without needing to put in the wrapper classes (The compiler still ads these so there is no real performance advantage, but it aids readability Variable Args - Just like in C++ you can now call a method with a variable number of arguments - so things like printf and scanf become possible printf - new printf method just like in C++ Scanners - this is a new method for reading input - similar to scanf Static imports - a new import static keywords allows you to specify a package prefix, which you can then miss out of the code aiding readability Enums - Java now has standard enums :-) Generics - Java now allows you to specify types in collectons and other calls. A good synopsis of this can be found at http://www.sitepoint.com/article/introducing-java-5/ thanks to Andy Grant for writing that article. |