tags:

views:

77

answers:

3

Hi,

I'm getting a list of strings from python code and need to read it in Java. When trying to read it, i get the hashCode

[Ljava.lang.Object;@7cf1bb78

I want to read the values in a list. In python my return is something like

return SUCCESS(OK, params={'data':nameList()})

How would I read this in Java and print the contents not the hashCode. Currently I'm doing like

Object getNames = new Object();
getName = getNameList(); // This is thru Apache XML RPC Client
System.out.println(getName);

Any help or suggestions?

A: 

Your getName is an array of objects, that's what the [Ljava.lang.Object;@7cf1bb78 notation means.

I suggest you iterate through the array and have a look at what it contains.

j-g-faustus
+1  A: 

You already have what you want. Try System.out.println(java.util.Arrays.toString(getName)); (the default toString() for an array in Java is not very useful).

Aaron Digulla
I tried System.out.println(java.util.Arrays.toString((Object[]) getAccount)); and the output was []Any other was to try it?
Panther24
This means you got an empty array back. Make sure that the server sends something useful.
Aaron Digulla
There was some code issue in Python also, anyway thanks for the solution, it works fine now :)
Panther24
A: 

The usual way to print out each item in a Java array would be something like:

for (Object name: (Object[]) getNameList()) {
  System.out.println(name);
}

But I suspect from your response to Aaron Digulla that (as he says) you're getting an empty array back. Try printing it out on the Python side and see if there's anything in it.

David Moles