我正在使用java.awt.Rectangle
类和交集方法。
Rectangle rect1 = new Rectangle(1, 2, 3, 4);
Rectangle rect2 = new Rectangle(2, 3, 4, 5);
Rectangle intersection = rect1.intersection(rect2);
System.out.println(intersection);
输出结果为:
java.awt.Rectangle[x=2,y=3,width=2,height=3]
如何获取每个号码?例如,为变量x = hello
或width = hi
分配答案。我想将输出格式化为:
Intersection: (2.0, 3.0, 2.0, 3.0)