Provider keySet() method in Java with Examples Last Updated : 06 Dec, 2018 Comments Improve Suggest changes Like Article Like Report The keySet() method of java.security.Provider class is used to return an unmodifiable Set view of the property keys contained in this provider. Syntax: public Set keySet() Return Value: This method returns a set view of the keys contained in this map. Below are the examples to illustrate the keySet() method: Program 1: Java // Java program to demonstrate // keySet() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { // Declaring int value i int i = 10; try { // creating the object of SecureRandom SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); // getting the Provider of the SecureRandom sr // by using method getProvider() Provider provider = sr.getProvider(); // Declaring the variable of set<Map> type Set<Object> keyset; // getting unmodifiable Set view of the keyset keyset = provider.keySet(); // Creating the object of iterator to iterate set Iterator iter = keyset.iterator(); // printing the set elements System.out.println("unmodifiable Set view : \n "); while (i > 0) { System.out.println("Value is : " + iter.next()); i--; } } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } } } Output: unmodifiable Set view : Value is : Alg.Alias.Signature.SHA1/DSA Value is : Alg.Alias.Signature.1.2.840.10040.4.3 Value is : Alg.Alias.Signature.DSS Value is : SecureRandom.SHA1PRNG ImplementedIn Value is : KeyStore.JKS Value is : Alg.Alias.MessageDigest.SHA-1 Value is : MessageDigest.SHA Value is : KeyStore.CaseExactJKS Value is : CertStore.com.sun.security.IndexedCollection ImplementedIn Value is : Signature.SHA256withDSA Program 2: Java // Java program to demonstrate // keySet() method import java.security.*; import java.util.*; public class GFG1 { public static void main(String[] argv) { // Declaring int value i int i = 10; try { // creating the object of Signature Signature sr = Signature.getInstance("SHA1withDSA"); // getting the Provider of the Signature sr // by using method getProvider() Provider provider = sr.getProvider(); // Declaring the variable of set<Map> type Set<Object> keyset; // getting unmodifiable Set view of the keyset keyset = provider.keySet(); // Creating the object of iterator to iterate set Iterator iter = keyset.iterator(); // printing the set elements System.out.println("unmodifiable Set view : \n "); while (i > 0) { System.out.println("Value is : " + iter.next()); i--; } } catch (NoSuchAlgorithmException e) { System.out.println("Exception thrown : " + e); } } } Output: unmodifiable Set view : Value is : Alg.Alias.Signature.SHA1/DSA Value is : Alg.Alias.Signature.1.2.840.10040.4.3 Value is : Alg.Alias.Signature.DSS Value is : SecureRandom.SHA1PRNG ImplementedIn Value is : KeyStore.JKS Value is : Alg.Alias.MessageDigest.SHA-1 Value is : MessageDigest.SHA Value is : KeyStore.CaseExactJKS Value is : CertStore.com.sun.security.IndexedCollection ImplementedIn Value is : Signature.SHA256withDSA Comment More infoAdvertise with us Next Article Provider keySet() 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 Properties keySet() method in Java with Examples The keySet() method of Properties class is used to create a set out of the key elements contained in the Properties. It basically returns a set view of the keys or we can create a new set and store the key elements in them. Syntax: public Set keySet() Parameters: This method accepts no parameters Re 2 min read Provider get() method in Java with Examples 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; other 3 min read TreeMap keySet() Method in Java with Examples In Java, keySet() method of TreeMap class is present inside java.util package in Java is used to create a set out of the key elements contained in the treemap. It basically returns a set view of the keys or we can create a new set and store the key elements in them in ascending order. Since the set 3 min read Map keySet() Method in Java with Examples This method is used to return a Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. Example:Java// Java Program Implementing Map // keySet() Method import java.util.*; public class GfG { public static void main(Str 2 min read Provider values() method in Java with Examples The values() method of java.security.Provider class is used to return an unmodifiable Collection view of the property values contained in this provider.Syntax: public Collection<Object> values() Return Value: This method returns a collection view of the values contained in this map.Below are t 3 min read Like