Provider get() method in Java with Examples Last Updated : 04 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The get() method of java.security.Provider class is used to return the value to which the specified key is mapped, or null if this map contains no mapping for the key. More formally, if this map contains a mapping from a key k to a value v such that (key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.) Syntax: public Object get(Object key) Parameters: This method takes the key as a parameter whose associated value is to be returned. Return Value: This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. Below are the examples to illustrate the get() method: Example 1: Java // Java program to demonstrate // get() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { // Declaring int values int i = 10, j = 10; try { // creating the object of KeyPairGenerator KeyPairGenerator sr = KeyPairGenerator.getInstance("DSA", "SUN"); // getting the Provider of the KeyPairGenerator sr // by using method getProvider() Provider provider = sr.getProvider(); // Declaring the variable of set<Map> type Set<Object> set; // getting unmodifiable Set view of the property entries set = provider.keySet(); // Creating the object of iterator to iterate set Iterator iter = set.iterator(); while (i > 0) { // getting the mapped value in element // using get() method Object element = provider.get(iter.next()); // printing the mapped value System.out.println("value is : " + element); i--; } } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } } } Output: value is : SHA1withDSA value is : SHA1withDSA value is : SHA1withDSA value is : Software value is : sun.security.provider.JavaKeyStore$DualFormatJKS value is : SHA value is : sun.security.provider.SHA value is : sun.security.provider.JavaKeyStore$CaseExactJKS value is : Software value is : sun.security.provider.DSA$SHA256withDSA Example 2: Java // Java program to demonstrate // get() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) throws Exception { try { // creating the object of KeyPairGenerator KeyPairGenerator sr = KeyPairGenerator.getInstance("DSA", "SUN"); // getting the Provider of the KeyPairGenerator sr // by using method getProvider() Provider provider = sr.getProvider(); // getting the mapped value in element // using get() method System.out.println("Trying to get the value of an unmapped key"); Object element = provider.get("geeks"); // printing the mapped value System.out.println("value is : " + element); } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } } } Output: Trying to get the value of an unmapped key value is : null Comment More infoAdvertise with us Next Article Provider get() method in Java with Examples R rohitprasad3 Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-security package Java-Provider +2 More Practice Tags : JavaMisc Similar Reads Provider getName() method in Java with Examples The getName() method of java.security.Provider class is used to return the name of this provider. Syntax: public String getName() Return Value: This method returns the name of this provider. Below are the examples to illustrate the getName() method: Example 1: Java // Java program to demonstrate // 2 min read Provider getInfo() method in Java with Examples The getInfo() method of java.security.Provider class is used to return a human-readable description of the provider and its services. This may return an HTML page, with relevant links. Syntax: public String getInfo() Return Value: This method returns a description of the provider and its services. B 2 min read Period get() method in Java with Examples The get() method of Period class in Java is used to get the value of the requested unit(YEARS, MONTHS or DAYS) given in the argument from this Period. Syntax: public long get(TemporalUnit unit) Parameters: This method accepts a single parameter unit of type TemporalUnit which is the unit to get requ 2 min read Provider getVersion() method in Java with Examples The getVersion() method of java.security.Provider class is used to return the version number for this provider Syntax: public double getVersion() Return Value: This method returns the version number for this provider. Below are the examples to illustrate the getVersion() method: Example 1: Java // J 2 min read Provider getProperty() method in Java with Examples The getProperty() method of java.security.Provider class is used to search for the property with the specified key in this property list. If the key is not found in this property list, the default property list, and its defaults, recursively, are then checked. The method returns null if the property 3 min read Like