import java.awt.Rectangle;
public class MyProgram {
public static void main(String[] args) {
Rectangle box = new Rectangle(5, 10, 20, 30);
System.out.println("Before: " + box.getX());
box.translate(25, 40);;
System.out.println("Should be 30, is that correct?");
System.out.println("After: " + box.getX());
}
}
Rectangle::translate() demo // mutable type
最新推荐文章于 2022-05-16 22:22:33 发布