Multiple generic interface separator: “,” or “&”
I was always using A<T extends I1, I2> but today, I saw A<T extends I1 & I2>.
What is the difference between these two notation?
Does it have a different meaning? Purpose?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
is a type
Awith two parametersTwhich must be a subtype ofI1I2You can read this as “A <preposition> type T which extends I1 <preposition> type I2”,
so
SortedMap<Key extends comparable, Value>is a “map from comparable type key to type value”is a type
Awith a single parameterTwhich must be a subtype ofI1and a subtype ofI2You can read this as “A <preposition> type T which extends I1 and I2” so a
SortedSerializableSet<T extends Serializable & Comparable>can be read “a sorted set of elements of type T which is both serializable and comparable”