Click here to watch in Youtube :
https://www.youtube.com/watch?v=S8vM6LMdvq8&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial: Generics in java | Java Generics [Unbounded wildcard in Java Generics] |
import java.util.ArrayList; import java.util.List; public class GenericDemo { public static void main(String[] args) { List<String> nameList = new ArrayList<String>(); nameList.add("Peter"); nameList.add("Ram"); printData(nameList); System.out.println("--------------------------"); List<Integer> integerList = new ArrayList<Integer>(); integerList.add(2); integerList.add(3); integerList.add(5); printData(integerList); } public static void printData(List<?> list) { for (Object obj : list) { System.out.println(obj); } } }Output
Peter Ram -------------------------- 2 3 5Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/GenericsDemo_unbounded_wildcard_App.zip?attredirects=0&d=1
Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/GenericsDemo_unbounded_wildcard_App
Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/539015917c8406e4be671410d713073b3971d1a5/BasicJava/GenericsDemo_unbounded_wildcard_App/?at=master
See also:
No comments:
Post a Comment