i want to over ride the to string method in my VO class

i want to over ride the to string method in my VO class

please give me the code for that
LVL 9
Manikandan ThiagarajanSenior consultantAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
objectsConnect With a Mentor Commented:
public class VO extends Whatever {

    ...

    @Override
    public String toString() {
        return ....;   // return string
    }
}
0
 
CEHJCommented:
0
 
Arabia_vnConnect With a Mentor Commented:
Really don't understand your problem. You override it as it should be
class EVO
{
@Override
public String toString()
    {
        return ....;   // return string
        // if you want to use default toString method simply call super.toString()
    }
}
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Manikandan ThiagarajanSenior consultantAuthor Commented:
how could i call that to  string method

could you please give me a example
0
 
objectsCommented:
String s = myVO.toString();

or it will get called implicitly when you do

String s = "My VO: "+myVO;
0
 
Arabia_vnCommented:
If you want to use it, simply initialize your class and call that method
VO myclass = new VO(//your constructor here);
String s = myclass.toString();
0
All Courses

From novice to tech pro — start learning today.