Skip to main content

toString() method help!! easy stuff

1 reply [Last post]
lilmzhotti
Offline
Joined: 2010-04-21
Points: 0

i need to implement the toString() method to return the vales in x,y
You (4,3)

what i did is:

public ToString()
{
private String Youx;
private String Youy;

public void setYoux(String youx)
{
youx = 4;

}

public void setYouy(String youy)
{
youy = 3;

}

public String getYoux()
{
return youx;

}

public String getYouy()
{
return youy;

}

I tried this and it keeps on coming up with an error
by using the toString() how could i display the position of You (4,3)??

please help

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
claudeabb
Offline
Joined: 2006-08-09
Points: 0

Hi,

I assume that you have created a class....

In this case you can override the methode toString()

public String toString(){
return "("+Youx+","+Youy+")";
}

Claude