What is .toString(); method in JAVA...? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

What is .toString(); method in JAVA...?

3rd Jun 2018, 12:59 PM
Prince Raj
3 Answers
+ 1
It is a method that returns a string representing nicely the data within the objects. So when you want to print an object, it will print that string rather than some random binary or error. It is a good idea to ensure t the toString function is implemented when you define a new class.
3rd Jun 2018, 4:38 PM
ifl
ifl - avatar
3rd Jun 2018, 1:01 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 1
To perform an ordering with a comma, use the ToString () method of the Array object    // Join + "," with ToString obejto method Array     var arr_semana = new Array ();     arr_semana [0] = " Monday ";     arr_semana [1] = "Tuesday";     arr_semana [2] = " Wednesday ";     var sorts = arr_semana.toString ();     document.write (sort); // output Monday, Tuesday, Wednesday
4th Jun 2018, 2:14 AM
Diego Alex Assis Portes
Diego Alex Assis Portes - avatar