Quiz: Pitfall
Run this code in the BlueJ code pad:
Rectangle box = new Rectangle(5, 10, 60, 90); Rectangle box2 = box; box.translate(100,100);
What is the value of box.getX() ? |
105 |
The translate method shifts the rectangle by 100 pixels to the right, so now x is 5 + 100 = 105. |
What is the value of box2.getX() ? |
105 |
Why did box2 change? See Cay's next video for an explanation! |