Test your knowledge
The
public class Party<T extends Sociable & Comparable<Sociable>>
line means:The generic type constraint specifies that
T
must implement either theSociable
orComparable<Sociable>
interfaces.The generic type constraint specifies that
T
must implement both theSociable
andComparable<Sociable>
interfaces.The class is a subclass of both the
Sociable
andComparable<Sociable>
classes.
Which of the following lines is equivalent to
List<SocialLion> lionsList = new ArrayList<SocialLion>();
in Java 9:List<SocialLion> lionsList = new ArrayList();
List<SocialLion> lionsList = new ArrayList<>();
var lionsList = new ArrayList<SocialLion>();
Which of the following lines uses the diamond notation to take advantage of Java 9 type inference:
List<SocialLion> lionsList = new ArrayList<>();
List<SocialLion> lionsList = new ArrayList();
var lionsList = new ArrayList<SocialLion>();
Java 9 allows...