Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.PriorityQueue;

public class Main {
    public static void main(String args[]) {
        PriorityQueue<Integer> p = new NoDuplicates<Integer>();
        p.add(1);
        p.add(2);
        p.add(1);
        for (int i = 0; i <= 2; i++) {
            System.out.println(p.poll());
        }

    }
}

class NoDuplicates<E> extends PriorityQueue<E> {
    public boolean add(E e) {
        boolean isAdded = false;
        if (!super.contains(e)) {
            isAdded = super.add(e);
        }
        return isAdded;
    }

}