This code compiles:
import java.io.Serializable;
import java.util.Arrays;
class Test<T extends Arrays & Serializable> { }
but if I replace the last line with
class Test<T extends Serializable & Arrays> { }
I get “interface expected here”. Why?
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.
From section 4.4 of the JLS:
So basically, if your bounds include a class, it has to be the first bound.
(Given that
Arrayscan’t be instantiated, it’s unclear why you would want a bound including it, mind you… was this just an example?)