This post originated from an RSS feed registered with Agile Buzz
by Joe Walnes.
Original Post: OT2004 : Taming the Tiger (Java 1.5)
Feed Title: Joe's New Jelly
Feed URL: http://joe.truemesh.com/blog/index.rdf
Feed Description: The musings of a ThoughtWorker obsessed with Agile, XP, maintainability, Java, .NET, Ruby and OpenSource. Mmm'kay?
This session was presented by Benedict Heal, and he was brilliant; concise, clear, humourous and extremely chilled out. Even the fact that Josh Bloch was listening in on his presentation didn't phase him.
Most of the new Java 1.5 features are already widely known. Generics, annotations, auto-boxing, enums, syntactic sugar, yada yada yada.
Some things that caught my eye:
-Xlint : a compiler flag to warn you when your code can be improved to take advantage of new features such as generics.
Generics are not available at runtime (unlike C#).
Use of generics all over the API, not just collections. For example, Class is a genericised type, so newInstance() returns the correct type.
List cannot be given a List. Makes sense really as otherwise you'd be able to add things that it shouldn't allow.
Genericised types can be constrained to only allow certain type. class Blah.
Wildcards allow even more flexibility: List extends MyThing> list = new ArrayList() // valid.
Or this: List super ExtendedThing> list = new ArrayList(); // valid
Generics are complicated :)
Annotations can be specified as source level, class level (available for inspection by class loader) or runtime level (available through reflection).
Variable parameters to a method. Defined like this: printf(String format, Object... args). The three dots are part of the syntax! Called like this: out.printf("Blah % blah % blah", 44, "hello", someObject). Note autoboxing comes into play too.
It's only a shame there isn't a feature such as the anonymous delegate in C#... now that is real power. Rock on Java 1.8.