Tuesday 16 May 2017

Java Tutorial: Generics in java | Java Generics [Unknown wildcard in Java Generics]


Click here to watch in Youtube :
https://www.youtube.com/watch?v=RA-2gwBjlPk&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial: Generics in java | Java Generics [Unknown wildcard in Java Generics] 
GenericDemo.java
import java.util.ArrayList;
import java.util.List;

public class GenericDemo
{

    public static void main(String[] args)
    {
        GenericDemo genericDemo = new GenericDemo();
        
        ArrayList<Integer> numberList = new ArrayList<Integer>();
        numberList.add(100);
        numberList.add(200);
        genericDemo.processElements(numberList);
        
        System.out.println("--------------------------------");
        
        ArrayList<String> nameList = new ArrayList<String>();
        nameList.add("Peter");
        nameList.add("Ram");
        genericDemo.processElements(nameList);

    }

    public void processElements(List<?> list)
    {
        for (Object o : list)
        {
            System.out.println(o);
        }
    }

}
Output
100
200
--------------------------------
Peter
Ram
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/GenericsDemo_unknown_wildcard_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/GenericsDemo_unknown_wildcard_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/539015917c8406e4be671410d713073b3971d1a5/BasicJava/GenericsDemo_unknown_wildcard_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment