Try to convert int type to string type

advertisements

First time posting. If I have two variables named x and y and they both are holding an int value; is it possible to convert the value they are holding into a string type? I am doing some school work and it's part of a class file names MyPoint. Here is the exact instruction:

"A method named toString that returns the values of the x and y in the following String format:(x,y)"

Can any body point me in the right direction? I keep getting errors saying that it is incompatible types.


You can convert a int to a string using:

Integer.toString(number)

or

String.valueOf(number)