Download presentation
Presentation is loading. Please wait.
Published byEgbert Green Modified over 9 years ago
1
Reference Types Data Structures & Problem Solving Using JAVA Second Edition Mark Allen Weiss Chapter 2 © 2002 Addison Wesley
2
Figure 2.1 An illustration of a reference: The Point object stored at memory location 1000 is referenced by both point1 and point3. The point object stored at memory location 1024 is referenced by point2. The memory locations where the variables are stored are arbitrary. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
3
Figure 2.2 The result of point3=point2: point3 now references the same object as point2. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
4
Figure 2.3 (A) The result of call-by-value. (a) b is a copy of yesButton; (b) after b.setLabel("No"): changes to the state of the object referenced by b are reflected in the object referenced by yesButton because these are the same object. (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
5
Figure 2.3 (B) The result of call-by-value. (c) after b=null: change to the value of b does not affect the value of yesButton; (d) after the method returns, b is out of scope. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
6
Figure 2.5 (A) Array expansion, internally: (a) At the starting point, arr represents 10 integers; (b) after step 1, original represents the same 10 integers. (continued) Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
7
Figure 2.5 (B) Array expansion, internally: (c) after steps 2 and 3, arr represents 12 integers, the first 10 of which are copied from original ; and (d) after step 4, the 10 integers are available for reclamation. Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
8
Figure 2.12 Common standard run-time exceptions Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
9
Figure 2.13 Common standard checked exceptions Data Structures & Problem Solving using JAVA/2E Mark Allen Weiss © 2002 Addison Wesley
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.