![]() |
VOOZH | about |
The checkedSet() method of java.util.Collections class is used to return a dynamically typesafe view of the specified set.
The returned set will be serializable if the specified set is serializable.
Since null is considered to be a value of any reference type, the returned set permits insertion of null elements whenever the backing set does.
Syntax:
public static Set checkedSet(Set s, Class type)
Parameters: This method takes the following argument as a parameter
Return Value: This method returns a dynamically typesafe view of the specified set.
Below are the examples to illustrate the checkedSet() method
Example 1:
Set: [Gopal, Ram, Verma] Typesafe view of Set: [Gopal, Ram, Verma]
Example 2:
Set: [20, 30, 40] Typesafe view of Set: [20, 30, 40]