Displaying an Object

Hi

If I have an instance of my self defined class City.

  • is it possible to display it in a field? I tried implementing toString(), asString(), objectFor(),… but nothing worked :-(
  • is it possible to convert a string, entered by a user, back into an instance of my class (like fromString())?

Thank you and regards
Birgit

I don’t know how it is when you work with JavaScript but in Java you have to do both ways (to and from string) yourself.

what should it show? (Do you have your own toString implementation??)

problem is that City is just a a function object.

dont know if you can overwrite the toString function so that that is used (by doing something with the prototype of the function object)

Yes, I did implement toString() as instance method of class City. But it seems not to be used. Displayed is ‘Object’