Wildcard:list<?> meaning is a List of elements of unknown type
1 2 3 4 5 6 7 |
public void Test (list<?> c) {for (int i= 0; i<c.size (); i++) {System.out.println (C.get (i) ); } } |
Maximum wildcard character: list<? Extends shape> represents a subtype of shape or shape
1 2 3 4 5 6 7 8 9 |
public class righttest {&NBSP;&NBSP;&NBSP;&NB Sp Static <T> void Test (collection<? extends t> from,collection<t> to) { for (t ele:from) { To.add (ele); } } public static void Main (String[] args) { list<object> ao= new arraylist<> (); list<string> as= new arraylist<> (); test (AS,AO); }} |
Minimum wildcard character: list<? Super Type> represents the type itself or the parent class of type
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 29 30 31 32 33 |
Package test; Import java.util.*; public class Treesettest {public static void main (string[] args) { |