PriorityQueue hashCode() in Java

hashCode(): This method is available in java.util.PriorityQueue class of Java.

Syntax:

int java.lang.Object.hashCode()

This method returns a hash code value for the object.

Parameters: NA

Returns: a hash code value for this object.

Exceptions: NA

Approach

Java

import java.util.PriorityQueue;

public class PriorityQueuehashCode {
    public static void main(String[] args) {

        PriorityQueue<Integer> priorityQueue =
new PriorityQueue<Integer>();

        priorityQueue.add(12);
        priorityQueue.add(5);
        priorityQueue.add(10);
        priorityQueue.add(2);

        System.out.println(priorityQueue.hashCode());

    }
}

Output:

653305407


No comments:

Post a Comment