Generics from "Java Generics and Collections"
-> package org.example ; import java.util.ArrayList ; import java.util.List ; public class Lists { public static < T > List < T > toList ( T [] arr ) { List < T > list = new ArrayList<>() ; for ( T elt : arr ) list .add( elt ) ; return list ; } } -> It may seem reasonable to expect that since Integer is a subtype of Number, it follows that List<Integer> is a subtype of List<Number>. But this is not the case, because the Substitution Principle would rapidly get us into trouble. It is not always safe to assign a value of type List<Integer> to a variable of type List<Number>. Consider the following code fragment: package org.example ; import java.util.ArrayList ; import java.util.List ; public class Main { public static void main ( String [] args) { List < Integer > ints = new ArrayList<>() ; ints .add( 1 ) ; ints .add( 2 ) ; List < Numb...