AbstractSet hashCode() Method in Java with Examples
The AbstractSet.hashCode() method in Java AbstractSet is used to fetch the hash code value of a particular this AbstractSet. A set consists of a number of buckets to store the elements. Each bucket has a unique identity and when an element is inserted into a bucket, its hashcode is matched with the identifier of the bucket, and if its a match the element is stored successfully. This is how the hash code works.
Parameters: The method does not accept any parameters.
Return Value: The method returns the hashcode value of the set.
Below programs are used to illustrate the working of AbstractSet.hashCode() Method:
Initial Set is: [4, Geeks, You, Welcomes] The hashcode value of the set-295204749
Initial Set is: [15, 20, 30, 40, 50] The hashcode value of the set: 155
Note: The same operation can be performed with any type of Set with variation and combination of different data types.
Please Login to comment...