?? testmypoint.java
字號:
public class TestMyPoint {
public static void main(String[] args) {
// Step 1: 定義對象start和end
MyPoint start = new MyPoint();
MyPoint end = new MyPoint();
// Step 2: 給 start and end的屬性賦值
start.x = 10;
start.y = 10;
end.x = 20;
end.y = 30;
// Step 3: 輸出start 和 end
System.out.println("Start point is " + start.toString());
System.out.println("End point is " + end.toString());
System.out.println();
// Step 5: 定義對象stray并賦值為對象 end,此時stray與end引用同一對象
MyPoint stray = end;
// Step 6: 輸出stray和end
System.out.println("Stray point is " + stray.toString());
System.out.println("End point is " + end.toString());
System.out.println();
// Step 7: 給stray重新賦值
stray.x = 47;
stray.y = 50;
System.out.println("Stray point is " + stray.toString());
System.out.println("End point is " + end.toString());//stray的改變也影響end,因為end和stray引用同一對象
System.out.println("Start point is " + start.toString());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -