+ 9
Explain tostring() method
7 Answers
+ 11
It converts a data type to a string. E.g:
int n=3;
String s=Integer.toString(n);
//now s also stores 3 as its value.
now, you can manipulate the number using string methods
note: Thanks Dan Walker for telling my mistake. We should use wrapper class to convert a data type to a string.
+ 5
For example:
int x = 5;
string con = x.ToString();
+ 3
Muhd Khairul Amirin Bin Yaacob Nitrocell
Just to point out a primitive int won't have access to toString(), it should be an object (like Integer)
+ 2
It converts the given input into string
For example:
int a=19;
String s=a. ToString();
In above example s value also 19 if we perform addition operation it performs cancatination operation becoz it is converted into string
+ 1
good for..
+ 1
Aruna Devi this is almost the same as previous answers, and also has the error that int, as a primitive, has no methods so you cannot invoke toString() on it
+ 1
https://www.google.co.in/url?sa=t&source=web&rct=j&url=https://www.javatpoint.com/understanding-toString()-method&ved=2ahUKEwj9_cCf_LzdAhXQfCsKHcx7BnkQFjAMegQICRAB&usg=AOvVaw1KDvr9tMXBvOAt9mdXXcaE&cshid=1537013190134
This link will help u to understand clearly