Open In App

List hashCode() Method in Java with Examples

Last Updated : 03 Dec, 2024
Comments
Improve
Suggest changes
2 Likes
Like
Report

This method is used to generate the hashCode for the given list.

Implementation:


Output
HashCode : 994

Syntax of Method

int hashCode()

  • Parameters: This function has no parameter.
  • Returns: This function returns the hashCode value for the given list.

Example of List hashCode() Method

Below programs show the implementation of this method.

Program 1:


Output
[10, 15, 20]
HashCode of List : 39886

Program 2: Below is the code to show implementation of list.hashCode() using Linkedlist.


Output
[10, 15, 20]
HashCode of List : 1586008

Reference: Oracle Docs


Explore