File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5480,6 +5480,68 @@ class Example3{
54805480
54815481</h3 >
54825482
5483+ <h3 ><i >Similarly,Using Wild Card in Upper Bound : </i ></h3 >
5484+
5485+ <h3 align =" Left " >
5486+
5487+ ```
5488+ ++++++++
5489+ + Eg-3 +
5490+ ++++++++
5491+
5492+ import java.util.ArrayList;
5493+ import java.util.List;
5494+
5495+ abstract class A2<T extends List<? extends Number>>{
5496+ public abstract T m(T a);
5497+ }
5498+
5499+ class Example3{
5500+ public static void main(String[] args) {
5501+ A2<List<Number>> a = new A2< List<Number>>() {
5502+ @Override
5503+ public List<Number> m(List<Number> a) {
5504+ return a;
5505+ }
5506+ };
5507+
5508+ List<Number> al = new ArrayList<>();
5509+ al.add(1);
5510+ al.add(2.0f);
5511+ al.add(3.33D);
5512+
5513+ System.out.println(a.m(al));
5514+
5515+
5516+
5517+ A2<List<Integer>> a1 = new A2< List<Integer>>() {
5518+ @Override
5519+ public List<Integer> m(List<Integer> a) {
5520+ return a;
5521+ }
5522+ };
5523+ List<Integer> al1 = new ArrayList<>();
5524+
5525+ al1.add(1);
5526+ al1.add(2);
5527+ al1.add(3);
5528+
5529+ System.out.println(a1.m(al1));
5530+
5531+ //Same for Double, Float,
5532+ // Long, Short, Byte,
5533+ //Which are extended by Number
5534+
5535+
5536+
5537+ }
5538+ }
5539+
5540+
5541+ ```
5542+
5543+ </h3 >
5544+
54835545
54845546
54855547</ul >
You can’t perform that action at this time.
0 commit comments