Test your knowledge
The
public class Party<T extends Sociable & Comparable<Sociable>>line means:The generic type constraint specifies that
Tmust implement either theSociableorComparable<Sociable>interfaces.The generic type constraint specifies that
Tmust implement both theSociableandComparable<Sociable>interfaces.The class is a subclass of both the
SociableandComparable<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...