Today I got lost in Java polymorphism. I have done something that I have thought that is impossible. Namely - I have EXTENDED interface.
I have created empty interface:
public interface Figure {}
Nothing new right now. Then I have created parametrized class Board with paramether that EXTENDS my interface!
public class Board< T extends Figure > {
T[][] board;
}
I thought it is not be possible! Nevertheless I was going further with my not understanding.
I have created class implementing Figure interface:
public class Cross implements Figure{}
And to my suprise I was able to do that:
Board b = new Board<Cross>();
Please help me and explain me this strange situation.
I know a little about polymorphism and I understand that Cross is Figure.
I am confused howcome any type is able to EXTEND interface, and howcome classes that implements interaface (not extending interface) are correct as paramether which extends interface.
Please help me and explain this polymorphicall mess. Thanks.