There's a lot wrong there, but let me just get the stupid question out of the way:
Are you sure this is exactly the code you're running? Are you sure you aren't calling o.getName()?
Posting an
SSCCE would help clear up any confusion about what you're doing, which would help you get better assistance.