下面为什么是false不是truepublic static void main(String[] args) {
  Point p1 = new Point(5,5);
  Point p2 = new Point(10,5);
  Line2D line = new Line2D.Double(p1,p2);
  System.out.println(line.contains(new Point(7,5)));
 }

解决方案 »

  1.   

    测试给定 Point2D 是否在此 Line2D 的边界内。此方法需要实现 Shape 接口,但是对于 Line2D 对象来说,它始终返回 false,因为线不包含任何区域。 
    JDK文档中这样说的!
      

  2.   

    public boolean contains(Point2D p)
    测试给定 Point2D 是否在此 Line2D 的边界内。此方法需要实现 Shape 接口,但是对于 Line2D 对象来说,它始终返回 false,因为线不包含任何区域。