Sunday, June 30, 2013

Java :: How To Override toString

How To Override toString
@Override public String toString()
{
return this.get(Field you want to return); // e.g: getName();
}

Why to use this kind override?
Sometimes we need to add for example a collection to a combo box so instead of looping
 over the object list you override the toString in that object to return one of the object variables

No comments:

Post a Comment