14 May String toString() method in Java
The toString() method in Java returns a String.
Syntax
Let us see the syntax,
String toString()
Parameters
The method has no parameters.
Example
The following is an example of toString(),
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