hi all,

this might be of interest to some of you:
http://developer.java.sun.com/developer/earlyAccess/adding_generics/index.html

Sun published version 2.0 of the early access drops for generics. This
release aslo includes:

* concise object array literals (aka varargs)
* jsr 201 - syntactic sugar like enums, autoboxing, static imports,
enhaced for construct.

also the generic impl is enhanced with variance support, and a variance
whitepaper is included.

I just skimmed through the whitepaper, but it sounds interesting. You
can add qualifiers when declare variables of generic type:
(-,+,*,=)

+ .. covariance     (read-only situations)
- .. contravariance (write-only situations)
* .. bivariance     (don't care about the type) [neither read from nor
write to instances)
= .. invariance     (both read and written to)
     [ can be obmitted, Set<A> == Set<=A> ]

an example for covariance:

<code>
Set<+Number> aReadOnlySet;

aReadOnlySet = new HashSet<Integer>( );
Iterator<+Number> i = aReadOnlySet.iterator( );
double sum = .0;
while ( i.hasNext( ) )  sum += i.next( ).doubleValue( );

</code>

<+Type> is used only for getting values from, not for setting.


allthough it is not fix, if this feature will ship with j2se 1.5.


at least sounds interesting ...

bye,

-- Jakob


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to