Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: Unable to Overload toString for Object Date: Thu, 13 Feb 2014 08:29:23 -0500 Organization: A noiseless patient Spider Lines: 30 Message-ID: References: <705891c8-b170-44c0-866f-48eec7b38c4d@googlegroups.com> <1138f80c-bc7c-4edd-a91b-fb5f8e2137d6@googlegroups.com> <0163eae2-3f35-4b96-a292-87a2fe3d3b03@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 13 Feb 2014 13:29:25 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="858a9d65d95f4ea4d355bd116aa2cdbf"; logging-data="10471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+w1aI3Sg6g3Qe+lz6zA5vB" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: Cancel-Lock: sha1:YzINciXmqS5HOlxR3z4PKLjy0xM= Xref: csiph.com comp.lang.java.programmer:27499 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