Hej mam problem, w książce: Podstawy Javy - Horstmana znalazłem przykład kolejki priorytetowej, niestety nie działa
import java.util.*;
/**
* Program demonstrujący zastosowanie kolejki priorytetowej
* @version 1.01 2012-01-26
* @author Cay Horstmann
*/
public class PriorityQueueTest
{
public static void main(String[] args)
{
PriorityQueue<GregorianCalendar> pq = new PriorityQueue<>();
pq.add(LocalDate.of(1906, 12, 9)); // G. Hopper
pq.add(LocalDate.of(1815, 12, 10)); // A. Lovelace
pq.add(LocalDate.of(1903, 12, 3)); // J. von Neumann
pq.add(LocalDate.of(1910, 6, 22)); // K. Zuse
System.out.println("Iteracja przez elementy...");
for (LocalDate date : pq)
System.out.println(date);
System.out.println("Usuwanie elementów...");
while (!pq.isEmpty())
System.out.println(pq.remove());
}
}
Po pierwsze nie importuje GregorianCalendar, po 2 w dokumentacji nie ma metody dla GregorianCalendar add(LocalDate.of()).
Przy imporcie java.time.LocalDate; (podpowiedz z Eclipse) dostaję takie błędy na pq.add(....) :
The method add(GregorianCalendar) in the type PriorityQueue<GregorianCalendar> is not applicable for the arguments (LocalDate)
Próbowałem na różne sposoby ale niestety nie mogę sobie z tym poradzić. Poproszę o pomoc,
Pozdrawiam