2005/07/07

I Generics sono l'equivalente dei template del C++ per JAVA. La prima volta che li ho visti ero un po' dubbioso... perchè aggiungere a Java le difficoltà del C++ ?

Perchè i Generics sono potenti e anche semplici!
Come farne a meno? :P

In sostanza si tratta di creare funzioni e classi generiche che utilizzano delle variabili o delle classi i cui TIPI che verrano definiti al primo uso (a compile time) .
In c++ i template sono POTENTI ma posso confondere e spaventare l'utente non smaliziato. In Java sono più semplici e appaiono piuttosto utilizzabili.

un po' di risorse....

Generics in J2SE 5.0
by Budi Kurniawan -- Generics are one of the most prominent language features in J2SE 5.0, but are you using them yet? Properly used, they allow greater flexibility, compile-time type safety, and fewer annoying and potentially unsafe casts. In this article, Budi Kurniawan shows how they work. (OnJava, molto ben fatto)

TUTORIAL PDF (della SUN, in inglese)

Nessun commento: