java - How can I define a generic class that implements two interfaces? -


I do not think this is a duplicate, but maybe (??)

Therefore, I want to create a general interface which allows only two embedded objects to be applied. Equally a costume interface is.

  Public Interface Summertime Semelist & lt; T comparative & lt; T & gt;, Alike & gt; {}  

If I explain it correctly, then Java now has a simple interface Summary SummaryList & lt; T, Alike & gt; , which is what I really want to achieve. I want AbstractSortedSimpleList & lt; T & gt; Where t is both Comparable & lt; T & gt; and equally to apply.

Later, I want to create a new class

  Public class sorted simple list & lt; T & gt; ObjectSurstSmallist & lt; T & gt; {}  

Here is a class sorted symbol list & lt; T & gt; , where T will have to implement the above interface. But my code is not working very well.

You can give several limitations to type the parameter:

  Public Interface Summarated Simplicity & lt; T comparison & lt; T & gt; & Amp; Similar & gt;  

Then, your sorted symlink will:

  class-sorted simlists & lt; T comparison & lt; T & gt; & Amp; Similar & gt; ObjectSurstSmallist & lt; T & gt; {}  

View

Each type variable declared as a type parameter is tied if no variable is declared for any type of variable If the object is assumed, then the object is assumed. If a bound is declared, then it contains either:

  • A type of variable, or

  • One Class or interface type T is likely to interface type I1 & amp; ... and amp; However, although you can not do such limitations for wildcards.

  • Note:

    This is only for type parameters.

    Reference:


Comments