Generics In Java
Date: May 27
Room: CGN C004
One of the main issues addressed by object-oriented languages like Java is
. Unfortunately, classes or methods designed for reuse often
fail to provide type-safety
to the programmer because the used types are
A good example of this are the collection classes in Java:
Since collection classes -for example java.utils.Stack- can store every
type of Object; the returntype of a function like 'pop()' cannot be more
specific than Object. When popping a String-object of a Stack the
programmer must explicitely cast
this Object to a String.
The Java-compiler is not able to determine statically if a cast will succeed
or not; so if the popped Object is not an instance of String the cast will
cause a runtime-failure.
or Parameterized Polymorphism
provide a way to abstract over
types without losing type-safety.
This presentation will cover:
- the basics of generics in OO languages
- generics in the new Java release Tiger (JavaTM 2 SDK, Standard Edition, Version 1.5.0)
- how generics are integrated in Java
- how generics could be integrated in Java