SLIDE 7 CS305j Introduction to Computing Arrays Part 2
7
Graphics methods with arrays
8These Graphics methods use arrays:
int[] xPoints = {10, 30, 50, 70, 90}; int[] yPoints = {20, 50, 35, 90, 15}; g.setColor(Color.GREEN); g.drawPolyline(xPoints, yPoints, 5); xPoints and yPoints are "parallel" arrays parallel arrays: two or more separate arrays, usually
- f the same length, whose elements with equal
indices are associated with each other in some way
drawPolyline(int[] xPoints, int[] yPoints, int length) fillPolygon(int[] xPoints, int[] yPoints, int length) drawPolygon(int[] xPoints, int[] yPoints, int length)
Method name