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:
- copying an array element by element;
- using class
System
methodarraycopy
; - using method
clone
.
Useful link: How to Copy an Array in Java
Self-assessment
Take the test.
Session 3 |