title: How can I see if two rectangles have one equal point using java?
body: <p>I have rectangle A = upper left point (-4,-1), bottom right point (-2-2) and rectangle B upper left point (-2,-2), bottom right point (-1,-3)</p>
  
  <p>then:</p>
  
  <pre><code>Rectangle first = new Rectangle(-4,-1,2,1);  //x1,y1,width,height
  Rectangle second = new Rectangle(-2,-2,1,1);
  </code></pre>
  
  <p>OK, I have 2 rectangles with 1 same point.
  I use first.intersects(second) and this returns false.. </p>
  
  <p>How can I use java to do this, I need something return True if One point or more into Rectangle A belongs Rectangle B?</p>
  
  <p>My code  now:</p>
  
  <p>public class GeometriaRectangle2 {</p>
  
  <pre><code>public static void main(String[] args) {
      Scanner lector = new Scanner(System.in);
      while (lector.hasNextLine()) {
          String a[] = lector.nextLine().split(",");
          int b[] = new int[a.length];
  
          for (int i = 0; i &lt; a.length; i++) {
              b[i] = Integer.parseInt(a[i]);
          }
          int c = Math.abs(b[0] - b[2]);
          int d = Math.abs(b[1] - b[3]);
          int e = Math.abs(b[4] - b[6]);
          int f = Math.abs(b[5] - b[7]);
          Rectangle r = new Rectangle(b[0], b[1], c, d);
          Rectangle r2 = new Rectangle(b[4], b[5], e, f);
          int tw = r.width;
          int th = r.height;
          int rw = r2.width;
          int rh = r2.height;
          if (rw &lt;= 0 || rh &lt;= 0 || tw &lt;= 0 || th &lt;= 0) {
              System.out.println(false);
          }
          int tx = r.x;
          int ty = r.y;
          int rx = r2.x;
          int ry = r2.y;
          rw += rx;
          rh += ry;
          tw += tx;
          th += ty;
          // overflow || intersect or attached
          if ((rw &lt; rx || rw &gt;= tx) &amp;&amp; (rh &lt; ry || rh &gt;= ty)
                  &amp;&amp; (tw &lt; tx || tw &gt;= rx) &amp;&amp; (th &lt; ty || th &gt;= ry)) {
              System.out.println(true);
          } else {
              System.out.println(false);
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Example: input: </p>
  
  <p>-3,3,-1,1,1,-1,3,-3</p>
  
  <p>-3,3,-1,1,-2,4,2,2</p>
  
  <p>output:</p>
  
  <p>False</p>
  
  <p>True</p>