[linux-l] generics in java

Oliver Bandel oliver at first.in-berlin.de
Do Jun 2 00:40:45 CEST 2005


On Wed, Jun 01, 2005 at 03:12:56PM +0200, Ivan Villanueva wrote:
[...] 
> Templates in Java:
> http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf
[...] 


Oh, wie steht es da:

  "Typically, the programmer knows what kind of data has been placed
   into a particular list. However, the cast is essential. The
   compiler can only guarantee that an Object will be returned by the
   iterator. To ensure the assignment to a variable of type Integer
   is type safe, the cast is required. Of course, the cast not only
   introduces clutter. It also introduces the possibility of a run
   time error, since the programmer might be mistaken."

Da kann einem ja schlecht werden. Man hört sonst doch immer,
Java wäre so schön sauber, was die Typen angeht.
Schöner als da oben kann man das Java-Chaos wohl nicht ausdrücken! :->

    "What if programmers could actually express their intent, and
     mark a list as being restricted to contain a particular data
     type? This is the core idea behind generics."

Aha. Tse...


Naja, ich lass das mal, und hör mal jetzt auf mir meinem rum-gemaule. ;-)

Weiß wieder einmal, wieso es gut war, mich mit dem Java-Krempel doch nicht
herum zu nerven... ;-)


Ciao,
   Oliver



Mehr Informationen über die Mailingliste linux-l