File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 872872 }
873873 ```
874874
875+ 47. how to write ?
876+
877+ ```java
878+ // works
879+ public class NumberList <E extends Number > extends ArrayList<E >
880+
881+ // does not work. how to write this
882+ class UntilNumberList<? extends Number > extends ArrayList<? >
883+ ```
884+
Original file line number Diff line number Diff line change 1+ package main ;
2+
3+ public interface Foo {
4+ public void process ();
5+ }
Original file line number Diff line number Diff line change 22
33import java .util .ArrayList ;
44import java .util .Arrays ;
5+ import java .util .List ;
56
67public class Main {
78
@@ -81,6 +82,22 @@ public static void main(String[] args) {
8182 System .out .println ("number list: " + rawNumberList );
8283 }
8384
85+ class PersonFoo extends Person implements Foo {
86+ public PersonFoo (String name ) {
87+ super (name );
88+ }
89+
90+ @ Override
91+ public void process () {
92+
93+ }
94+ }
95+
96+ public static void process (List <? extends Foo > list ) {
97+ for (Foo elem : list ) {
98+ }
99+ }
100+
84101 public static <T extends Comparable <T >> int countGreaterThan (T [] anArray , T x ) {
85102 int count = 0 ;
86103
Original file line number Diff line number Diff line change @@ -15,4 +15,7 @@ public Stream<E> parallelStream() {
1515 public Stream <E > stream () {
1616 return null ;
1717 }
18- }
18+ }
19+
20+ // how to write this
21+ // class UntilNumberList<? extends Number> extends ArrayList<?>
You can’t perform that action at this time.
0 commit comments