-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWildCardUse.java
More file actions
28 lines (24 loc) · 871 Bytes
/
Copy pathWildCardUse.java
File metadata and controls
28 lines (24 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*------------------------------------------------------------------------------
* Oracle Certified Professional Java SE 8 Programmer Exam 1Z0-809
* A Comprehensive OCPJP 8 Certification Guide
* by SG Ganesh, Hari Kiran and Tushar Sharma
------------------------------------------------------------------------------*/
// This program demonstrates the usage of wild card parameters
import java.util.List;
import java.util.ArrayList;
class WildCardUse {
static void printList(List<?> list){
for(Object element: list)
System.out.println("[" + element + "]");
}
public static void main(String []args) {
List<Integer> list = new ArrayList<>();
list.add(10);
list.add(100);
printList(list);
List<String> strList = new ArrayList<>();
strList.add("10");
strList.add("100");
printList(strList);
}
}