Java Signature toString() method with Examples Last Updated : 04 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The toString() method of java.security.Signature class is used to return a string representation of thesignature object, providing information that includes the state of the object and the name of the algorithm used. Syntax: public String toString() Return Value: This method returns a string representation of this signature object. Below are the examples to illustrate the toString() method: Example 1: Java // Java program to demonstrate // toString() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { try { // creating the object of Signature Signature sr = Signature.getInstance("SHA1withDSA"); // getting the String representation // by using method toString() String status = sr.toString(); // printing the provider name System.out.println("Status : " + status); } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } } } Output: Status : Signature object: SHA1withDSA Example 2: Java // Java program to demonstrate // toString() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { try { // creating the object of Signature Signature sr = Signature.getInstance("NONEwithDSA"); // getting the String representation // by using method toString() String status = sr.toString(); // printing the provider name System.out.println("Status : " + status); } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } } } Output: Status : Signature object: NONEwithDSA Comment More infoAdvertise with us Next Article Java Signature toString() method with Examples rohitprasad3 Follow Improve Article Tags : Misc Java Java-Functions Java-security package Java-Signature +1 More Practice Tags : JavaMisc Similar Reads String toString() Method in java with Examples String toString() is the built-in method of java.lang which return itself a string. So here no actual conversion is performed. Since toString() method simply returns the current string without any changes, there is no need to call the string explicitly, it is usually called implicitly. Syntax : publ 1 min read StringWriter toString() method in Java with Examples The toString() method of StringWriter Class in Java is used to get the String representation of this StringWriter instance. This method does not accept any parameter and returns the required String value. Syntax: public String toString() Parameters: This method accepts does not accepts any parameter 2 min read Scanner toString() method in Java with Examples The toString() method of java.util.Scanner class returns the string representation of this Scanner. The exact format is unspecified. Syntax: public String toString() Return Value: This function returns the string representation of this scanner. Below program illustrates the above function: Program 1 1 min read StringBuffer toString() method in Java with Examples The toString() method of StringBuffer class is the inbuilt method used to returns a string representing the data contained by StringBuffer Object. A new String object is created and initialized to get the character sequence from this StringBuffer object and then String is returned by toString(). Sub 2 min read Pattern toString() Method in Java with Examples toString() method of a Pattern class used to return the string representation of this pattern. This return the regular expression from which this pattern was compiled. Syntax: public String toString() Parameters: This method accepts nothing as parameter. Return value: This method returns a string re 1 min read Like