What does this class declaration mean in Java?

I just study trees and one thing I don't understand is class declarations:

For example: class binarysearchtree < T extensions comparable

Now, please explain the contents in brackets and ""?

Can you quote any of my good sources? thank you.

Solution

This declares a class with a single generic type parameter Because for a binary search tree, it must compare two items, which needs to be specified so that the compiler can validate it

The part in angle brackets is the type parameter T and its constraints, which indicates:

>No matter what t is, it should extend comparable (< T extends comparable <... > >). > The comparator should be able to compare itself with T or super class T ()

Because t can usually be anything, it limits the choice of types that make sense to implement the search tree

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>