Getting point on a rectangle border To get points which lie on the border of a rectangle, I use 4 for loops. At first I thought about creating Rectangle and using PathItterator, but it confused me very much. Is there a better way than mine?

int r = 5;
int x = 0;
int y = 0;
int length = r * 2 + 1;
for (int i = 0; i &lt; length; i++) {
    System.out.print(String.format("(%d,%d) ", x - r + i, y - r));
}
System.out.println();
for (int i = 0; i &lt; length; i++) {
    System.out.print(String.format("(%d,%d) ", x - r + i, y + r));
}        System.out.println();

for (int i = 0; i &lt; length; i++) {
    System.out.print(String.format("(%d,%d) ", x - r , y - r+i));
}        System.out.println();

for (int i = 0; i &lt; length; i++) {
    System.out.print(String.format("(%d,%d) ", x + r , y - r+i));
}
System.out.println();
Most rectangles have a length and a width.  I’ve never heard of a rectangle with a radius, but it would be known as a square.

More constructively:

System.out.print(String.format("(%d,%d) ", x - r + i, y - r));


Could be written as:

System.out.format("(%d,%d) ", x - r + i, y - r);