For example, let's say I 开发者_JAVA百科am adding a set of objects I created, called myClass
(which contains a string) to myList
and then I wish to use the list and pass it to a GUI list. Is there a way to populate that GUI list only with the value of that string in myClass
?
Every object should respond to printString
message with some meaningful string presentation of itself. You can write your own #printString for your object and use it.
Even better for your case could be implementation of asString
conversion method, which converts your object to a string.
I believe the methods you are looking for are printString and/or displayString.
精彩评论