❮ String Methods
Example
String myStr = "Hello, World!";
System.out.println(myStr.toString());Definition and Usage
The toString() method returns the string itself.
This method may seem redundant, but its purpose is to allow code that is treating the string as a more generalized object to know its string value without casting it to String type.
Syntax
public String toString()Technical Details
| Returns: | The String object itself. |
|---|---|
| Java version: | Any |