Explore Connect Documentation
Snippets
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
class Point {
  private double x = 0;
  private double y = 0;
  public Point() {} // empty constructor
  public Point(final int x, final int y) {
    this.x = x;
    this.y = y;
  }
  public void setX(final double x) {
    this.x = x;
  }
  public void setY(final double y) {
    this.y = y;
  }
  public double getX() {
    return this.x;
  }
  public double getY() {
    return this.y;
  }
  public void reflect() {
    this.x = -this.x;
    this.y = -this.y;
  }
  public String toString() {
    return "(" + this.x + ", " + this.y + ")";
  }
}
public class PointExample {
  public static void main(final String[] args) {
    final Point p = new Point(1, 2);
    System.out.println(p);
    p.reflect();
    System.out.println(p);
  }
}
Press desired key combination and then press ENTER.