VOOZH about

URL: https://www.geeksforgeeks.org/java/provider-get-method-in-java-with-examples/

⇱ Provider get() method in Java with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Provider get() method in Java with Examples

Last Updated : 4 Dec, 2018
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:
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:
Output:
Trying to get the value of an unmapped key
value is : null
Comment