Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
This doesn't work:
int number = 1; String numberstring = IntToString(number);
I get "The method IntToString(int) is undefined for the type (myclassname)"
I must be tired here. What the heck am I forgetting?
IntToString method
myclassname
String.valueof(number)
Try this.
int number = 1; String numberstring = Integer.toString(number);
Add a comment
You can do either:
String numberstring = number.toString();
or
String numberstring = Integer.toString(number)
or (as a tricky thing sometimes I do this)
String numberstring = 1 + "";
Why not this :
int number = 1; String numberstring = number+"";
Also make sure that :
Is there IntToString method in your class file - myclassname? Is the arguement types are matching?
IntToString
These ones are the ones that seems to work "out of the box", without importing any special classes:
String numberstring = String.valueOf(number); String numberstring = Integer.toString(number); String numberstring = number + "";
One way to do this with very little code would be like this:
int number = 1; String numberstring = number + "";
Are you expecting this -
int numb = 1; String val = String.valueOf(numb);
int number=1; String S = String.valueOf(number);
try this code... works for me :)
In Java, int to String is simple as
String numberstring = String.valueOf(number);
This applies to Android too.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
IntToString methodin your class file -myclassname? Is the arguement types are matching?String.valueof(number)