n00b Mistake

Last week I was starting up a new project at work, and after bouncing some ideas off a co-worker, I thought I had a great idea for implementing a portion of the project.  So off I went, headphones on, music blasting and coding away.  Compile.Test.Wait a sec...my perfect idea doesn't work!!!

Here's an overview of what I implemented:

Class A is a factory, and via a static call generates an instance of Class B.  Class A has two private fields that hold some objects, and I pass a reference of both objects to Class B.  Class B has a method,someMethod(), that when called sets the two object references mentioned earlier to null.  

I thought, "Hey, isn't passing objects done in a pass by reference in java?  If I set the references to null in Class B, then they should automatically be set to null in Class A, right?"

Wrong!  Anyone see the error?  What I was actually doing was just setting Class B's reference to the objects to null, not actually nulling the object itself...doh!!  What happened is what I feel is a classic case of trying to be too clever for my own good....

So I know it was a pretty big novice mistake, and am a little embarrassed to write it out, but I'm mostly doing it to remind me not to make it again, and if anyone out there reads this, hopefully they can learn from it too.