"I'd also like to tell you a couple of interesting things about object lifetime. In Java, it's very difficult to accidentally destroy an object. If you have a reference to an object, it is alive.

You can't change references to an object, and you can't increase or decrease them. Additionally, you can't create a reference to an object. You can only assign a reference or set it to null."

"I think I understand, Ellie. So if I erase (or set to null) all references to an object, then I'll never again be able to get a reference to that object or access it, right?"

"That's correct. However, you can also have the situation where the system has too many live objects that are not being used. Programmers often create dozens of objects, store them in various lists for processing, and then never empty these lists.

Objects that programmers don't need are usually simply marked as eligible for garbage collection. Nobody deletes them from lists. As a result, large Java programs often become too big as more and more unused objects remain in memory.

You won't run into this soon, but every time I'll remind you about these unused objects, as well as the right way to dispose of them."

"OK. Thank you, Ellie, for helping me better understand references."

undefined
6
Task
New Java Syntax, level 6, lesson 4
Locked
One large array and two small ones
1. Create an array of 20 numbers. 2. Populate it with values from the keyboard. 3. Create two arrays of 10 numbers each. 4. Copy the large array into the two small ones: half the numbers into the first small array, and the second half into the second small array. 5. Display the second small array, e
undefined
6
Task
New Java Syntax, level 6, lesson 4
Locked
Street and houses
1. Create an array of 15 integers. 2. Populate it with values from the keyboard. 3. Let the array index represent the house number. The array value at a particular index represents the number of people living in the corresponding house. Houses with odd numbers are located on one side of the street.
undefined
6
Task
New Java Syntax, level 6, lesson 4
Locked
2 arrays
1. Create an array of 10 strings. 2. Create an array of 10 numbers. 3. Enter 10 strings from the keyboard, and put them in an array of strings. 4. In each element of the number array, record the length of the string whose string array index coincides with the current index of the number array. Displ