1

I would like your help in understanding what this syntax means:

class Node<K extends Comparable<? super K>, V>

What does the ? stands for?

And isn't there one < missing?

2

2 Answers 2

9

The ? stands for "some unknown type". In this specific case it's ? super K which means "some unknown type that's a base type of K (i.e. "super class of" or "interface implemented by") .

And no, there's no < missing: you have two < and two >, they match up.

Practically it means that Node has two type arguments: K which probably represents a key, which must be Comparable to itself and V which probably represents a value.

Sign up to request clarification or add additional context in comments.

Comments

0

the generics/wildcards tutorial explains this syntax

5 Comments

I downvoted this because answers that are just a single link are not considered to be good answers.
@Joachim Sauer - right, cut-n-paste is better than the link to the exact answer on the technology owner's site ...
Who's talking about cut-and-paste? Did you read the question I linked to? The issue has been discussed.
@Joachim Sauer - the author of the question is confused with the syntax of wildcards in generics that is precisely what the article behind the link I gave explains. I did read the question you gave a link to, and I do believe that being a robot is not the best attitude to develop in yourself. In this particular case a single link IS a good answer.
@bobah: and it's great if you helped, my personal opinion is something different, but that's no problem. A down-vote is not a personal attack. Obviously at least 2 people think that your answer is good, so you got the upvotes. I don't see the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.