Session 3 |
Reference semantics
A variable refers to the specific location in memory where the value is stored.
Copy of an array
The reference semantics is important for example for making a copy of an array. If we need to copy an array, we can do:
- copy an array element by element;
- use class
System
methodarraycopy
(check API); - use method
clone
(check API).
Useful link: How to Copy an Array in Java
Self-assessment
Take the test.
Session 3 |