fork download
  1. class Main {
  2. public static void main(String[] args) {
  3. System.out.println("Hello World!"); // Display the string.
  4. Point p1 = new Point(3, 5);
  5. Point p2 = p1;
  6. p1 = null;
  7. System.out.println(p2.getx());
  8. }
  9. }
  10.  
  11. class Point {
  12. private int x;
  13. private int y;
  14.  
  15. public Point(int x, int y) {
  16. this.x = x;
  17. this.y = y;
  18. }
  19.  
  20. public int getx() {
  21. return x;
  22. }
  23. public int gety() {
  24. return y;
  25. }
  26. public void setx(int x) {
  27. this.x = x;
  28. }
  29. public void sety(int y) {
  30. this.y = y;
  31. }
  32. }
Success #stdin #stdout 0.03s 245632KB
stdin
Standard input is empty
stdout
Hello World!
3