java - Generic Types Related But Incompatible -


still trying grasp generics concept... line

public interface filestructure<l extends filestructurelevel<l>, r extends filestructureresource> extends nodestructure<l, r> 

gives following message:

type argument l#1 not within bounds of type-variable l#2   l#1,l#2 type-variables:     l#1 extends filestructurelevel<l#1> declared in interface filestructure     l#2 extends nodestructurelevel<l#2> declared in interface nodestructure 

now, seem trivial, type bounds different. however, confusing actually, narrowing bound, since

public interface filestructurelevel<e extends filestructurelevel> extends nodestructurelevel<filestructurelevel> 

so whatever l1 is, going extend l2. why mismatch? anyone?

further, given declaration

public interface nodestructure<l extends nodestructurelevel<l>, r extends nodestructureresource> 

and

public class filestructureresource implements nodestructureresource<file> 

why doesn't first line produce similar error related r, below:

type argument r#1 not within bounds of type-variable r#2   r#1,r#2 type-variables:     r#1 extends filestructureresource declared in interface filestructure     r#2 extends nodestructureresource declared in interface nodestructure 

change code

public interface filestructurelevel<e extends filestructurelevel>     extends nodestructurelevel<filestructurelevel> 

to

public interface filestructurelevel<e extends filestructurelevel>     extends nodestructurelevel<e> 

and happy. stands, filestructurelevel<l> not nodestructurelevel<l> required nodestructure, instead nodestructurelevel<filestructurelevel>. compiler trying tell you.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -