bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java String toString() Method

❮ 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

Previous

Java String toLowerCase() Method

Next

Java String toUpperCase() Method