Originally posted by Peter Chase:
...
In your specific example, if your Map actually contains objects that are all Strings, then both pieces of code will actually produce the same result. But don't think that means that casting to String and call toString() are generally the same, because they absolutely aren't.
Just to continue that thought...
If your Map actually contains objects that are all, say, Integers, then trying to typecast the return value from getAValue() will throw a ClassCastException. Calling toString(), however, will return a String representation of the retrieved Integer.