Welcome to object oriented programming. Enjoy your stay.
Java doesn't have pointers, though it is "okay" (sort of) to think of them as such if it helps you understand. Java has references instead. The easiest way to think of a reference is like this:
- Imagine you have a box full of stuff. Light bulbs, toys, spare parts, tools, whatever. The box only changes when you add something into it.
- Imagine now that you label each item in the box with a number. That number tells you which object you're referring to. You can always write in all your record books that you need part XYZ for some job. There's only one part though. You have to add another one if you need more.
- Imagine that when you have no more use for a part, you rip the label off. Your wife (being very tidy and hating all the junk you keep around) checks your box every once in awhile to see if there's any stuff without a label. If she finds anything, she throws it out. (Men and their junk, eh?)
The labels are like references. They allow you to always keep track of the specific instance of the object. The objects in the box are just like your Java objects. Your wife in this scenario, is the garbage collector. And finally, the box is an object too, so it just happens to be an ArrayList.
Make sense?
