Skip to content

Commit af1d2c9

Browse files
committed
Additional lambda fixes
1 parent 0ce5b38 commit af1d2c9

File tree

3 files changed

+67
-0
lines changed

3 files changed

+67
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package test;
2+
3+
import java.util.stream.Collectors;
4+
import java.util.stream.DoubleStream;
5+
import java.util.stream.IntStream;
6+
7+
public class Test_Java8a extends Test_ {
8+
9+
String test = "testing";
10+
11+
public int getI(int i) {
12+
return test.charAt(i);
13+
}
14+
15+
public double[] getTest() {
16+
return IntStream.range(0, 4).mapToDouble(i -> this.getI(i)).toArray();
17+
}
18+
19+
private static String whitespaceString(int width) {
20+
return IntStream.range(0, width).mapToObj(i -> " ").collect(Collectors.joining());
21+
}
22+
23+
public static void main(String[] args) {
24+
double[] cc = new Test_Java8a().getTest();
25+
assert(cc[2] == 's');
26+
double[] dd = new Test_Java8a().values().toArray();
27+
assert(dd[2] == 2);
28+
assert(whitespaceString(10).length() == 10);
29+
System.out.println("Test_Java8a OK");
30+
}
31+
32+
public DoubleStream values() {
33+
return IntStream.range(0, 4)
34+
.mapToDouble(this::get);
35+
}
36+
37+
38+
public double get(int row) {
39+
return row;
40+
}
41+
42+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package test;
2+
3+
public class Test_inta implements Test_inta1 {
4+
5+
// note that Integer does not work to implement Number.
6+
public String testInt(Integer i) {
7+
// TODO Auto-generated method stub
8+
return null;
9+
}
10+
11+
@Override
12+
public String testInt(Number n) {
13+
// TODO Auto-generated method stub
14+
return null;
15+
}
16+
17+
18+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package test;
2+
3+
public interface Test_inta1 {
4+
5+
public String testInt(Number n);
6+
7+
}

0 commit comments

Comments
 (0)