+ 2
Help!!!What is toString()
public String toString(){ }
7 ответов
+ 4
in c++ it converts the input value to a string. dare say java does the same. but i dont java.. keeps me up all night. someone else can explain what it means in java
+ 4
toString() is a method to return a String object representing any value that is passed to it
+ 3
Let's say you want to create a Person class. Person owns the attributes name, age and whatever you can think of.
Now try to print an instance of person. There will be an obscure output on the console (object id @ hash code of the object). That is usually not what you want, right?
So you can override the toString method of your class. In toString you can create your own return string.
+ 2
aiiiiii!!!!! sololearn and you guys make me happy😊😊.thank you guys!
+ 1
thanks, you learned me something about c++.
0
thanks @deddy Tandean you guys are awesome.