13.2. Migrating from Java Generics

Most programmers who have worked with Java tend to find the migration to J# fairly straightforward. Microsoft has done a great job at making J# look and feel very much like Java. In fact, depending on the nature of your application, the move to J# can be fairly transparent. To date, the J# language specification has appeared to mostly mimic many of the syntactic tendencies of Java. Now, with the Java platform introducing generics as part of its 1.5 (Tiger) release, this is a point where J# and Java will diverge more than they have in the past.

If you look at the rationale for introducing generics into Java and .NET, you get the idea that both teams were certainly motivated by a common set of objectives. Both platforms seemed to view the lack of parameterized types as representing a shortcoming they'd both like to overcome. And, if you've been using generics under Java, you'll likely find the transition to J# generics to be relatively painless. The generics syntax for each Java and J# syntax certainly share a number of similarities. That said, generics is one area where you'll find more variation in syntax than you might be expecting.

The similarities between Java and J# generics definitely come to a hard stop at syntax. The underlying implementations of Java and .NET generics are very different ideologically. When generics were introduced into the Java platform, they were done so in a manner that attempted to limit the impact on the existing ...

Get Professional .NET 2.0 Generics now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.