Java Tutorial #51 - Java PriorityQueue Class with Examples (Collections)

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • Java Tutorial #51 - Java PriorityQueue Class with Examples (Collections)
    In this video by Programming for Beginners we will learn Java PriorityQueue Class with Examples, using Java Tutorial videos.
    The PriorityQueue class provides the functionality of the heap data structure.
    Unlike normal queues, priority queue elements are retrieved in sorted order.
    Suppose, we want to retrieve elements in the ascending order. In this case, the head of the priority queue will be the smallest element. Once this element is retrieved, the next smallest element will be the head of the queue.
    NOTE: The elements of a priority queue may not be sorted. However, elements are always retrieved in sorted order.
    PriorityQueue Methods:
    add() method
    offer() method
    peek() method
    remove() method
    poll() method
    Using Iterator for PriorityQueue objects.
    ==========
    We can learn Java Programming language to make web applications or mobile applications for android phones and several other applications for windows, Mac OS and Unix operating systems. Also we can make android applications using Java programming. The concepts covered will be related to basic java and core java that will help you in your next interview questions. You can use any version of Java but all concepts will be same for all java versions. I will be using Java SE 8.
    Java is a high-level programming language. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.
    Java is a MUST for students and working professionals to become a great Software Engineer specially when they are working in Software Development Domain.
    Java Tutorial for Beginners Playlist:
    • Java Tutorial
    Java JDK:
    www.oracle.com...
    Eclipse IDE:
    www.eclipse.or...
    CZcams Gears:
    Microphone: amzn.to/3iIk5K3
    Mouse: amzn.to/35irmNF
    Laptop: amzn.to/3iG0jyD
    #JavaTutorial #JavaForBeginners #Programming #Java
    ============================
    LIKE | SHARE | COMMENT | SUBSCRIBE
    Thanks for watching :)

Komentáře • 17

  • @sravanipudu
    @sravanipudu Před 2 měsíci +1

    I am very confused about this concept.. now it's all cleared my doubts .. thank you

  • @paarthiban8452
    @paarthiban8452 Před rokem +2

    At last I understood the algorithm behind the priority queue...really nice work buddy.👌

  • @MahaDev-cx1ij
    @MahaDev-cx1ij Před 2 měsíci +1

    Very impressive and wow presentation

  • @jeyanthan360
    @jeyanthan360 Před rokem +1

    For a capacity-constrained queue, the difference between add() and offer() methods are,
    add() always returns true and throws an exception if it can't add the element, whereas
    offer() is allowed to return false if it can't add the element.

    • @thesquarefish
      @thesquarefish Před rokem

      Don't know if you'll see this message but why would anyone use add() over offer() if add() might error and offer() won't?

    • @jeyanthan360
      @jeyanthan360 Před rokem

      @@thesquarefish
      if you know that the queue has enough capacity to hold the element you want to add, it is generally better to use the add() method. On the other hand, if you are not sure whether the queue has enough capacity or not, or if you want to handle queue overflow gracefully, you can use the offer() method.
      And actually add() method was created first . After sometimes, from the problem faced by the add() ,offer() has been created. So most text books are using the old methods as an example for adding elements in a priority queue, these youtube videos are also teaching in traditional bookish way. But offer() is good compared to add() we can use that too, totally our choice.

    • @thesquarefish
      @thesquarefish Před rokem

      @@jeyanthan360 But from a purely functional standpoint, offer() is always equal to or better than add()?

    • @jeyanthan360
      @jeyanthan360 Před rokem

      @@thesquarefish Yessss u r Right

    • @thesquarefish
      @thesquarefish Před rokem

      @@jeyanthan360 Ok thank u for answering

  • @ACUCSPRADEEPB-up9ne
    @ACUCSPRADEEPB-up9ne Před rokem +1

    Wow 👍

  • @nishikantmandaokar9353
    @nishikantmandaokar9353 Před rokem +1

    You r good.. but lil bit more knowledge is there then it will be good

  • @2412Anand
    @2412Anand Před 2 dny

    why it is 1 3 2 4 why not 1 2 3 4