I just tried it exactly as you have it below and it worked for me with
no compiler error.
Did you somehow pick up a type-erased version of one of the classes,
maybe a classpath problem?
JVS
On Wed, 2005-12-14 at 00:46 -0500, Charles Fry wrote:
> Hi,
>
> I am getting an error when compiling the following block of code:
>
> public class NeighborIndex<V, E extends Edge<V>> implements GraphListener<V, E>
> {
> public void edgeAdded(GraphEdgeChangeEvent<V, E> e)
> {
> E edge = e.getEdge();
> V source = edge.getSource();
> }
> }
>
> The error is:
>
> incompatible types
> found : java.lang.Object
> required: V
> V source = edge.getSource();
> ^
>
> My understanding of generics suggests that the compiler should have
> already known that E extends Edge<V>, and should thus have expected V
> instead of Object in the above block of code. Obviously I was wrong. Any
> suggestions as to what I am missing, and how I can fix this?
>
> thanks,
> Charles
>
|