Java List hashCode() Method

The hashCode() method of List interface returns the hash code value for this list.

Syntax

Parameters

NA

Specified By

hashcode in interface Collection<E>

Overrides

This method overrides hashCode in class Object

Returns

The hashCode() method returns the hash code value for this list.

Example 1

Test it Now

Output:

Hash Code for 5 : 5
Hash Code for 51 : 51
Hash Code for 52 : 52

Example 2

Test it Now

Output:

Hash Code : -1772261557

Example 3

Test it Now

Output:

Exception in thread "main" java.lang.NullPointerException
	at com.javaTpoint.JavaListHashCodeExample3.main(JavaListHashCodeExample3.java:12)
Next TopicJava List




Latest Courses