Answers for "build heap in java"

6

heap in java

In Java PriorityQueue can be used as a Heap.

Min Heap
PriorityQueue<Integer> minHeap = new PriorityQueue<>();


Max Heap:
PriorityQueue<Integer> maxHeap = new PriorityQueue<>(Comparator.reverseOrder());
Posted by: Guest on August-31-2020
0

java heap example

package com.journaldev.test;package com.journaldev.test;
public class Memory {
 public static void main(String[] args) { // Line 1 int i=1; // Line 2 Object obj = new Object(); // Line 3 Memory mem = new Memory(); // Line 4 mem.foo(obj); // Line 5 } // Line 9
 private void foo(Object param) { // Line 6 String str = param.toString(); //// Line 7 System.out.println(str); } // Line 8
}
Posted by: Guest on October-16-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language