You are given a simple dynamic array class; i.e. an array that can grow on demand. One can think of an array as a function from integers to objects. The value of that function at n is the element at index n, or null if n is not a valid index.

Implement the asFunction method to yield that function. Use an anonymous inner class.