Click here to watch in Youtube :
https://www.youtube.com/watch?v=M7LaKqw7tfw&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial: Generics in java | Java Generics [Lower bounded wildcard in Java Generics] |
Java Tutorial: Generics in java | Java Generics [Lower bounded wildcard in Java Generics] |
import java.util.ArrayList;
import java.util.List;
public class GenericDemo
{
public static void main(String[] args)
{
List<Integer> integerList = new ArrayList<Integer>();
addIntegers(integerList);
List<Number> numberList = new ArrayList<Number>();
addIntegers(numberList);
}
public static void addIntegers(List<? super Integer> list)
{
list.add(new Integer(50));
System.out.println(list);
}
}
Output[50]
[50]
Click the below link to download the code:
No comments:
Post a Comment