test/tools/javac/lambda/8071432/T8071432.java

changeset 2730
a513711d6171
equal deleted inserted replaced
2724:e5b93c508212 2730:a513711d6171
1 /*
2 * @test /nodynamiccopyright/
3 * @bug 8071432
4 * @summary structural most specific and stuckness
5 * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java
6 */
7
8 import java.util.Arrays;
9 import java.util.Collection;
10
11 class T8071432 {
12
13 static class Point {
14
15 private double x, y;
16
17 public Point(double x, double y) {
18 this.x = x;
19 this.y = y;
20 }
21
22 public double getX() {
23 return x;
24 }
25
26 public double getY() {
27 return y;
28 }
29
30 public double distance(Point p) {
31 return Math.sqrt((this.x - p.x) * (this.x - p.x) +
32 (this.y - p.y) * (this.y - p.y));
33 }
34
35 public double distance() {
36 return Math.sqrt(this.x * this.x + this.y * this.y);
37 }
38
39 public String toString() {
40 return "(" + x + ":" + y + ")";
41 }
42 }
43
44 public static void main(String[] args) {
45 Collection<Point> c = Arrays.asList(new Point(1.0, 0.1));
46 System.out.println("------- 1 ---------------");
47 System.out.println(c.stream().reduce(0.0,
48 (s, p) -> s += p.distance(), (d1, d2) -> 0));
49 }
50 }

mercurial