import java.util.Map;
import java.util.WeakHashMap;

public class Point {
  private static Map<String, Point> instances = 
    new WeakHashMap<String, Point>();

  public double x, y; // Mutable. What problems could this cause?

  private Point(double x, double y) {
    this.x = x;
    this.y = y;
  }
	
  public static Point getInstance(double x, double y) {
    String key = x + "," + y;
    if (!instances.containsKey(key))
      instances.put(key, new Point(x, y));
    return instances.get(key);
  }
	

  @Override
  public String toString() {
    return "(" + x + ", " + y + ")";
  }
}