Lecture 02
Lecture 02
Swakkhar Shatabda
Memory Leaks
In C/C++, dynamically allocated (using new/malloc)
arrays/objects are required to be released (using free/delete) to
avoid memory leaks. In java, this is done by garbage collection!
(programmers heaven/hell?)
Java Solution
No pointers
No explicit deallocation of memory
When memory can no longer be accessed, garbage collection
eventually reclaims the memory
United International University CSI 211: Object Oriented Programming 15
Array Initialization
All array elements are given an initial value that depend on the type
Array Initializers
One can initialize arrays to a list of values
The syntax is slightly different for declaration statements and
assignments
There is no way to indicate repeated values in the initializer
Example
final static int zero = 0;
Thank you