Reputation: 47
Whenever i run the method, i get an error which comes with as numbers
The following is what i have as my code.
public String getAccount()
{
String s = "Listing the accounts";
for(List l:lists)
s+=" "+list.toString;
Return s;
}
I get the following when i run this method:
List@some numbers
For the List class, i just have a constructor which appoints parsed variables into local variables.
DOes someone know what this means?
Upvotes: 0
Views: 67
Reputation: 116286
This means that you haven't overridden the toString
method in your (apparently) custom List
class. The default implementation (Object.toString
) displays output like you show above:
The
toString
method for classObject
returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
You should override toString
in your custom classes, in order to provide the desired output.
Upvotes: 2