The syntax > in Java

后端 未结 3 553
猫巷女王i
猫巷女王i 2021-01-18 01:28

I have couple of thoughts regarding the following:

public interface MaxStack>

1-Why does the class tha

3条回答
  •  爱一瞬间的悲伤
    2021-01-18 01:44

    1) the class has a type parameter T with a bound (extends Comparable ), this parameter is passed to the interface (which need the same bound here). When passing a type parameter, you must not repeat its bound - why you should do so?

    2) like 1), the type parameter has its bound declared, no repeat neccessary.

    To clarify:

    The first type parameter occurence (here behind the interface or class name) is its declaration. Any following occurence is a usage. You even never would write a variables type declaration each time you use it, right?

提交回复
热议问题