14 May String toString() method in Java
The toString() method in Java returns a String.
Syntax
Let us see the syntax,
1 2 3 |
String toString() |
Parameters
The method has no parameters.
Example
The following is an example of toString(),
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import java.util.*; public class StudyopediaDemo { public static void main(String args[]) { String message1 = new String("Studyopedia provides free learning content!"); System.out.println("String: "+message1); System.out.println("Result = "+message1.toString()); } } |
Output
The following is the output,
No Comments