-
-
Save darrenbkl/1e77a7ebf06314b7070054c94467d433 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void printList(List<? extends Number> numList) { | |
for (Number n : numList) { | |
System.out.println(n); | |
} | |
} | |
List<Integer> integerList = new ArrayList<>(Arrays.asList(1, 2, 3)); | |
List<Double> doubleList = new ArrayList<>(Arrays.asList(1.1, 2.2, 3.3)); | |
printList(integerList); // 1, 2, 3 | |
printList(doubleList); // 1.1, 2.2, 3.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment