Re: Unable to Overload toString for Object
On 2/12/2014 11:24 PM, Ojesh Dugar wrote:
[... lots of ugly double-spaced googlegroup grunge ...]
Object[] array = (Object[]) createResult;
this line itself gives an error.
Exception in thread "main" java.lang.ClassCastException: java.util.HashMap cannot be cast to [Ljava.lang.Object;
at XMLRPC.Testing.main(Testing.java:64)
Your original post said the code's output was
bugs=[Ljava.lang.Object;@2ee5e48a
.... which is what you'd get if it output "bugs=" and the string
representation of an Object[] array. On closer inspection, though,
I see that there's nothing in the code that could have produced
the "bugs=" part. Conclusion: You misreported the output or you
reported the output of some slightly different piece of code, and
I was wrong to believe that "[Ljava.lang.Object;@2ee5e48a" was the
string representation of `createResult'. Sorry about that -- but
in the future, please make sure your code and your reported output
belong together.
If `createResult' refers to a HashMap (as the exception text
indicates), you can proceed as markspace showed. If it's an array
(in a follow-up you wrote that "two items are returned [...] both
are array of hashes") you'll need to access its individual elements.
--
Eric Sosman
esosman@comcast-dot-net.invalid