8. วัตถุสิ่งของ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 8-39  ตัวแปรอ้างอิง final เปลี่ยนค่าไม่ได้ แต่เปลี่ยนข้อมูลของอ็อบแจกต์ที่ถูกอ้างอิงได้
  final int[] a = {1,2,3,4};
  a[0] = 24;                      // ทำได้ 
  a = new int[]{4,3,2,1};         // ทำไม่ได้ 
  final Point p = new Point(3,4);
  p.setXY(1,2);                   // ทำได้ 
  p = new Point(0,0);             // ทำไม่ได้ 
©2009 S.Prasitjutrakul