Re: Why Generics?



> My reason is simply that people have been discussing adding "templates" to
Java
> since well before C# was invented (or at least publicly admitted to).
Same
> goes for enums.

Enums were truly needed. They eliminated a class of (what I consider to be)
type-related errors that in my experience was very common: using the wrong
constant in the wrong context. Like substituting LAYOUT.LEFT_JUSTIFIED
for LAYOUT.WEST in a layout manager.

There's a C# feature that I also think is desperately needed in Java.

C# allows you to use the SAME syntax for fields and nyladic (zero arguments)
methods. This allows you to abstract the implementation of the field so
that fields can be re-implemented as methods without breaking existing code.

This is a very common occurrence. SOmething starts out with a static value
and ends up being a dynamic value.

I'm getting someone on the Java committee to propose this.


.



Relevant Pages

  • Re: seeking advice for "translate" Fortran code to Java code
    ... with these features that just don't exist in Java: ... Labeled COMMON blocks Blank COMMON ... Java arrays are always what C would call arrays of pointers ... FORTRAN I/O class that would emulate formatted and binary I/O. ...
    (comp.lang.fortran)
  • Re: OO refactoring trial ??
    ... As long as the concrete Python classes follow the form ... other common-to-all-taunts behavior, perhaps a common constructor, or ... in both Python and Java. ... return values derive from a common base class, ...
    (comp.lang.python)
  • Re: Somewhat of a big lie about OO in java book?
    ... clever meaning in Eiffel that might some day make it to Java. ... How about "common" as in common to all objects of the class. ... default instance var int y; ...
    (comp.lang.java.help)
  • Re: seeking advice for "translate" Fortran code to Java code
    ... with these features that just don't exist in Java: ... Labeled COMMON blocks Blank COMMON ... Java arrays are always what C would call arrays of pointers ...
    (comp.lang.fortran)
  • Re: Java sockets and readLine
    ... >>> see the next character. ... > versions of Java were not implemented this way. ... It was quite common to ... > see server software written that did a readLine() on a socket that ...
    (comp.lang.java.programmer)