erich musick's blog

Personal blog of Erich Musick - student, programmer, web designer, and Christ follower.

March 17th, 2006

The Joys of Java

Posted At: 1:34am by Erich Musick
So I was working on Project Foundry stuff today and spent an hour or two trying to figure out why an object did not contain the data that I expected it to have. The query was executing correctly, returning the correct results and even populating the object correctly. Somewhere along the line, though, the data was getting lost. I finally realized that it was because of Java's all-pointer approach. I added this user object to a response object and then populated it with some other data. Since adding the user object to the response didn't actually clone the object but just sent along a memory address, successive changes to the user object caused a change in all "copies" of the object. I changed the user class so that it implements the Cloneable interface and that solved my problem.

Anyway ... it's another late night and I'm not sure how much sense I'm making, so I'm going to shower and go to bed.
Read 2668 times.
[ Printer Friendly Version ]


Comment on entry entitled "The Joys of Java"

You may use BBCode within your posts, a reference is available here.
Name: 
E-mail Address: 
Web Site: 
Subject: 

Notify me of replies to this comment.
Auth Code
Please type the letters in the image above:

E-mail Article
Send to:
From: