// API callback
related_results_labels_thumbs({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-913600556879440043"},"updated":{"$t":"2024-01-01T15:38:08.302+05:30"},"category":[{"term":"Java"},{"term":"General"},{"term":"C Plus Plus Programming"},{"term":"Selenium Automation Testing"},{"term":"High Performance Computing"},{"term":"PPL"},{"term":"Parallel Computing"},{"term":"My Vlogs"},{"term":"Blogging Tips"},{"term":"Skill Development Lab"},{"term":"Compiler"},{"term":"Website Designing"},{"term":"Data Structures"},{"term":"Android"},{"term":"Database"},{"term":"CUDA"},{"term":"OPENMP"},{"term":"YouTube Tips"},{"term":"Youtube"},{"term":"C Programming"},{"term":"How To Write Blog"},{"term":"Android App Development"},{"term":"Salesforce"},{"term":"Multithreading"},{"term":"Networking"},{"term":"Swing"},{"term":"LEX \u0026 YACC"},{"term":"Linux"},{"term":"Ubuntu"},{"term":"Mysql"},{"term":"Nanded City Pune"},{"term":"GATE"},{"term":"Cloud Computing"},{"term":"MS Excel Formulas \u0026 Functions"},{"term":"Applet"},{"term":"Computer Networks"},{"term":"Google Forms"},{"term":"SQL"},{"term":"MPI"},{"term":"OpenMPI"},{"term":"Socket Programming"},{"term":"Thread Pool"},{"term":"Amazon Links Summary"},{"term":"Fedora"},{"term":"Guest Blogging"},{"term":"Python"},{"term":"SDL"},{"term":"Wine"},{"term":"Abbreviations in Computer Science"},{"term":"Amazon Affiliate Program"},{"term":"Dia Software"},{"term":"Lisp"},{"term":"Mathematics"},{"term":"OPENCL"},{"term":"Udemy Courses"},{"term":"Unboxing \u0026 Review"},{"term":"Vedic Mathematics"},{"term":"Vocabulary"}],"title":{"type":"text","$t":"Computer Revolution (www.comrevo.com)"},"subtitle":{"type":"html","$t":""},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https:\/\/www.comrevo.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/-\/Skill+Development+Lab?alt=json-in-script\u0026max-results=6"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comrevo.com\/search\/label\/Skill%20Development%20Lab"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"},{"rel":"next","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/-\/Skill+Development+Lab\/-\/Skill+Development+Lab?alt=json-in-script\u0026start-index=7\u0026max-results=6"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"30"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"6"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-446577838238300408"},"published":{"$t":"2020-10-07T13:04:00.006+05:30"},"updated":{"$t":"2020-10-07T13:07:33.454+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Swing"}],"title":{"type":"text","$t":"How To Add Image in Java Swing JFrame using JLabel"},"content":{"type":"html","$t":"\u003Cp\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp;\u003Cspan\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003C\/span\u003E\u003Cspan\u003EIn this post, we will see How To Add Image in Java Swing JFrame using JLabel.\u003C\/span\u003E\u003C\/span\u003E\u003C\/p\u003E\u003Ca name='more'\u003E\u003C\/a\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan\u003E\u003Cb\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003C\/b\u003ETo know\u0026nbsp;\u003Cb\u003Ewhat is Swing, how Swing is different from Applet, how to create Swing Application\u003C\/b\u003E; check this post\u0026nbsp;\u003Ca href=\"http:\/\/www.comrevo.com\/2017\/08\/swing-in-java-with-example.html\" target=\"_blank\"\u003Ehttp:\/\/www.comrevo.com\/2017\/08\/swing-in-java-with-example.html\u003C\/a\u003E\u003Cb\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003Cspan\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; To know\u0026nbsp;\u003Cb\u003Ehow to generate event in Java Swing along with Java Swing program for addition of two numbers\u003C\/b\u003E; check this post\u0026nbsp;\u003Ca href=\"http:\/\/www.comrevo.com\/2017\/08\/java-swing-program-for-addition-of-two-numbers.html\" target=\"_blank\"\u003Ehttp:\/\/www.comrevo.com\/2017\/08\/java-swing-program-for-addition-of-two-numbers.html\u003C\/a\u003E\u0026nbsp;\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan\u003E\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan\u003E\u003Cspan\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Here, we will see Java Swing program for adding Image on frame.\u003C\/span\u003E\u003Cspan\u003E\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cspan\u003E\u003Cspan\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In Swing, there are different ways to add image on frame e.g. using paint() method or using JPanel class.\u0026nbsp;\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cdiv\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cspan\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; But, the best way to add image is by using \u003Cb\u003EJLabel \u003C\/b\u003Eclass. We need to create JLabel object. While creating JLabel object, we need to pass object of \u003Cb\u003EImageIcon\u003C\/b\u003E class. While creating object of ImageIcon, we need to pass object of \u003Cb\u003EBufferedImage\u003C\/b\u003E class. To create object of BufferedImage, we need to call \u003Cb\u003Eread()\u003C\/b\u003E method of \u003Cb\u003EImageIO\u003C\/b\u003E class. We have to pass object of \u003Cb\u003EFile\u003C\/b\u003E class into read() method as parameter. File object\u0026nbsp;\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cspan\u003Erefers our \u003Cb\u003Eimage file\u003C\/b\u003E.\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cspan\u003E\u003Cspan\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; Go through the following program:\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003Cspan\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cspan\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003Cdiv dir=\"ltr\" style=\"orphans: auto; widows: 1;\" trbidi=\"on\"\u003E\u003Cdiv style=\"font-family: \u0026quot;times new roman\u0026quot;;\"\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cb\u003EProgram (SwingImage.java):\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003Eimport javax.swing.*;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003Eimport java.awt.*;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003Eimport java.awt.image.BufferedImage;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003Eimport java.io.File;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003Eimport javax.imageio.ImageIO;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003Epublic class SwingImage\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E{\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp;public static void main(String args[]) throws Exception\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;{\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;Abc obj=new Abc();\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E}\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003Eclass Abc extends JFrame\u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E{\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; public Abc() throws Exception\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp;{\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;setLayout(new FlowLayout());\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l1=new JLabel(\"Full Name:\");\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t1=new JTextField();\u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;t1.setColumns(20);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l2=new JLabel(\"Class:\");\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t2=new JTextField();\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;t2.setColumns(20);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l3=new JLabel(\"College:\");\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t3=new JTextField();\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;t3.setColumns(20);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel l4=new JLabel(\"City\");\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JTextField t4=new JTextField();\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;t4.setColumns(20);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JButton b1=new JButton(\"Submit\");\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JButton b2=new JButton(\"Reset\");\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l1);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t1);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l2);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t2);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l3);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t3);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(l4);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(t4);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(b1);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(b2);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;BufferedImage myPicture = ImageIO.read(new File(\"thread life cycle.jpeg\"));\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;JLabel picLabel = new JLabel(new ImageIcon(myPicture));\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;add(picLabel);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan\u003E\u0026nbsp;\u003C\/span\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;setVisible(true);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;setSize(250,400);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; }\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E}\u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003C\/div\u003E\u003C\/div\u003E\u003C\/td\u003E\u003C\/tr\u003E\u003C\/tbody\u003E\u003C\/table\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cb style=\"font-family: \u0026quot;Times New Roman\u0026quot;; widows: 2;\"\u003E\u003Cspan style=\"font-size: large;\"\u003EHow To Run:\u003C\/span\u003E\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan\u003E\u003Cspan\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\u003Ctr\u003E\u003Ctd\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog\/swing$ javac SwingImage.java\u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog\/swing$ java SwingImage\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003C\/div\u003E\u003Cdiv\u003E\u003C\/div\u003E\u003C\/div\u003E\u003C\/td\u003E\u003C\/tr\u003E\u003C\/tbody\u003E\u003C\/table\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003Cspan style=\"font-family: \u0026quot;Times New Roman\u0026quot;; widows: 2;\"\u003E\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr style=\"font-family: \u0026quot;Times New Roman\u0026quot;; widows: 2;\" \/\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EOutput:\u0026nbsp;\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/div\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-shlHQWwEUjg\/X31uCzSxI8I\/AAAAAAAAEgU\/wYYYTu1PR30NYbnP-SR6tiIRxf2ZBFsrACNcBGAsYHQ\/s490\/SwingImage.png\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"490\" data-original-width=\"243\" src=\"https:\/\/1.bp.blogspot.com\/-shlHQWwEUjg\/X31uCzSxI8I\/AAAAAAAAEgU\/wYYYTu1PR30NYbnP-SR6tiIRxf2ZBFsrACNcBGAsYHQ\/s16000\/SwingImage.png\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\u003Cbr \/\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003Cb\u003ECheck other posts on Java Programming in this link\u0026nbsp;\u003Ca href=\"http:\/\/www.comrevo.com\/2017\/08\/java-programming.html\"\u003Ehttp:\/\/www.comrevo.com\/2017\/08\/java-programming.html\u003C\/a\u003E\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\u003C\/div\u003E\u003C\/div\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comrevo.com\/feeds\/446577838238300408\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/10\/how-to-add-image-in-java-swing-jframe-using-jlabel.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/446577838238300408"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/446577838238300408"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/10\/how-to-add-image-in-java-swing-jframe-using-jlabel.html","title":"How To Add Image in Java Swing JFrame using JLabel"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/1.bp.blogspot.com\/-shlHQWwEUjg\/X31uCzSxI8I\/AAAAAAAAEgU\/wYYYTu1PR30NYbnP-SR6tiIRxf2ZBFsrACNcBGAsYHQ\/s72-c\/SwingImage.png","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-9181867006948546724"},"published":{"$t":"2020-09-01T16:44:00.000+05:30"},"updated":{"$t":"2020-09-05T12:32:34.868+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Multithreading"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"}],"title":{"type":"text","$t":"Thread Life Cycle in Java | Different Phases in the Life Cycle of Thread | Thread Life Cycle Diagram"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In this post, we will see\u0026nbsp;\u003C\/span\u003E\u003Cspan style=\"font-size: large;\"\u003EThread Life Cycle in Java | Different Phases in the Life Cycle of Thread | Thread Life Cycle Diagram | thread life cycle in java,thread life cycle,thread life cycle in java with example,thread life cycle diagram,thread life cycle methods in java,life cycle of thread in java,life cycle of thread.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003EWatch this video to know different phases in the life cycle of thread:\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Ciframe allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" frameborder=\"0\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/7EptP0bli2w\" width=\"640\"\u003E\u003C\/iframe\u003E\n\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EWatch on YouTube:\u0026nbsp;\u003Ca href=\"https:\/\/www.youtube.com\/watch?v=7EptP0bli2w\" target=\"_blank\"\u003Ehttps:\/\/www.youtube.com\/watch?v=7EptP0bli2w\u003C\/a\u003E\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Ca name='more'\u003E\u003C\/a\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003ECheck following Diagram:\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-o6I9l_Fxwh4\/X04s9QuNb_I\/AAAAAAAAEcE\/1186MLF5wYMAS5w78f3JdkoTyN1IGk2KQCNcBGAsYHQ\/s1600\/thread%2Blife%2Bcycle.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"434\" data-original-width=\"653\" src=\"https:\/\/1.bp.blogspot.com\/-o6I9l_Fxwh4\/X04s9QuNb_I\/AAAAAAAAEcE\/1186MLF5wYMAS5w78f3JdkoTyN1IGk2KQCNcBGAsYHQ\/s1600\/thread%2Blife%2Bcycle.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comrevo.com\/feeds\/9181867006948546724\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/09\/thread-life-cycle-in-java-different-phases-in-life-cycle-of-thread.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/9181867006948546724"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/9181867006948546724"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/09\/thread-life-cycle-in-java-different-phases-in-life-cycle-of-thread.html","title":"Thread Life Cycle in Java | Different Phases in the Life Cycle of Thread | Thread Life Cycle Diagram"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/img.youtube.com\/vi\/7EptP0bli2w\/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-7330057389442063011"},"published":{"$t":"2020-08-16T23:59:00.000+05:30"},"updated":{"$t":"2020-08-16T23:59:12.035+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"}],"title":{"type":"text","$t":"Deque in Java | Deque Implementation in Java | Deque Data Structure Java with Example"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In this post, we will see Deque in Java | Deque Implementation in Java | Deque Data Structure Java with Example\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ca name='more'\u003E\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EWatch this video to know about Deque in Java | Deque Implementation in Java | Deque Data Structure Java with Example:\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ciframe allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" frameborder=\"0\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/wNd0Jqsu3go\" width=\"640\"\u003E\u003C\/iframe\u003E\n\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EWatch on YouTube:\u0026nbsp;\u003Ca href=\"https:\/\/www.youtube.com\/watch?v=wNd0Jqsu3go\" target=\"_blank\"\u003Ehttps:\/\/www.youtube.com\/watch?v=wNd0Jqsu3go\u003C\/a\u003E\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EProgram Code: (DequeProg.java)\u0026nbsp;\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\n\u003Ctr\u003E\u003Ctd\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eimport java.util.*;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003Epublic class DequeProg {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; public static void main(String args[]) {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; Deque q = new ArrayDeque();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; int head;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.addFirst(10);\u0026nbsp; \/\/offerFirst()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.addFirst(25);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.addLast(22);\u0026nbsp; \/\/offerLast()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.addLast(18);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; try{\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.removeFirst();\u0026nbsp; \/\/pollFirst()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.removeFirst();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.removeLast();\u0026nbsp; \u0026nbsp;\/\/pollLast()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.removeLast();\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.removeLast();\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; }\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;catch(Exception e) {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue is empty\");\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp;}\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E}\u003C\/span\u003E\u003C\/td\u003E\u003C\/tr\u003E\n\u003C\/tbody\u003E\u003C\/table\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cbr \/\u003E\n\u003Cdiv dir=\"ltr\" style=\"orphans: auto; text-align: left; text-indent: 0px; widows: 1;\" trbidi=\"on\"\u003E\n\u003Cdiv style=\"font-family: 'times new roman';\"\u003E\n\u003Cdiv style=\"margin: 0px;\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EOutput:\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\n\u003Ctr\u003E\u003Ctd\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog$ javac DequeProg.java\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003ENote: DequeProg.java uses unchecked or unsafe operations.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003ENote: Recompile with -Xlint:unchecked for details.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog$ java DequeProg\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: []\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [25, 10]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [25, 10, 22]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [25, 10, 22, 18]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 22, 18]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [22, 18]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [22]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: []\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue is empty\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/td\u003E\u003C\/tr\u003E\n\u003C\/tbody\u003E\u003C\/table\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comrevo.com\/feeds\/7330057389442063011\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/deque-in-java-deque-implementation-in-java-with-example.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/7330057389442063011"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/7330057389442063011"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/deque-in-java-deque-implementation-in-java-with-example.html","title":"Deque in Java | Deque Implementation in Java | Deque Data Structure Java with Example"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/img.youtube.com\/vi\/wNd0Jqsu3go\/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-7704380134975969879"},"published":{"$t":"2020-08-16T23:42:00.002+05:30"},"updated":{"$t":"2020-08-16T23:42:33.298+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"}],"title":{"type":"text","$t":"Queue in Java | Queue in Collection Framework in Java | Queue Data Structure in Java Example"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u003C\/span\u003E\u003Cspan style=\"font-size: large;\"\u003EIn this post, we will see Queue in Java | Queue in Collection Framework in Java | Queue Data Structure in Java Example\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ca name='more'\u003E\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EWatch this video to know about\u0026nbsp;\u003C\/span\u003E\u003Cspan style=\"font-size: large;\"\u003EQueue in Java | Queue in Collection Framework in Java | Queue Data Structure in Java Example:\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Ciframe allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" frameborder=\"0\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/_9rsWbpRFoc\" width=\"640\"\u003E\u003C\/iframe\u003E\n\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EWatch on YouTube:\u0026nbsp;\u003Ca href=\"https:\/\/www.youtube.com\/watch?v=_9rsWbpRFoc\" target=\"_blank\"\u003Ehttps:\/\/www.youtube.com\/watch?v=_9rsWbpRFoc\u003C\/a\u003E\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EProgram Code: (QueueProg.java)\u0026nbsp;\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\n\u003Ctr\u003E\u003Ctd\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eimport java.util.*;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003Epublic class QueueProg {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; public static void main(String args[]) {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; Queue q = new LinkedList();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; int head;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(10);\u0026nbsp; \/\/offer()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(25);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(22);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(18);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; try {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u0026nbsp; \/\/poll()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; }\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; catch(Exception e) {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;System.out.println(\"Queue is Empty\");\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp;}\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E}\u003C\/span\u003E\u003C\/td\u003E\u003C\/tr\u003E\n\u003C\/tbody\u003E\u003C\/table\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cbr \/\u003E\n\u003Cdiv dir=\"ltr\" style=\"orphans: auto; text-align: left; text-indent: 0px; widows: 1;\" trbidi=\"on\"\u003E\n\u003Cdiv style=\"font-family: 'times new roman';\"\u003E\n\u003Cdiv style=\"margin: 0px;\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EOutput:\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\n\u003Ctr\u003E\u003Ctd\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog$ javac QueueProg.java\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003ENote: QueueProg.java uses unchecked or unsafe operations.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003ENote: Recompile with -Xlint:unchecked for details.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog$ java QueueProg\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: []\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 25, 22]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 25, 22, 18]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [25, 22, 18]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [22, 18]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [18]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: []\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue is Empty\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/td\u003E\u003C\/tr\u003E\n\u003C\/tbody\u003E\u003C\/table\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comrevo.com\/feeds\/7704380134975969879\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/queue-in-java-queue-in-collection-framework-in-java.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/7704380134975969879"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/7704380134975969879"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/queue-in-java-queue-in-collection-framework-in-java.html","title":"Queue in Java | Queue in Collection Framework in Java | Queue Data Structure in Java Example"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/img.youtube.com\/vi\/_9rsWbpRFoc\/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-239714100273384946"},"published":{"$t":"2020-08-11T15:40:00.000+05:30"},"updated":{"$t":"2020-08-16T23:53:35.770+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"}],"title":{"type":"text","$t":"Priority Queue in Java | Priority Queue Using Heap | Priority Queue Implementation in Java"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In this post, we will see\u0026nbsp;\u003C\/span\u003E\u003Cspan style=\"font-size: large;\"\u003EPriority Queue in Java | Priority Queue Using Heap | Priority Queue Implementation in Java\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Ca name='more'\u003E\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EWatch this video to know about Priority Queue in Java | Priority Queue Using Heap | Priority Queue Implementation in Java:\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Ciframe allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" frameborder=\"0\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/deTpicgkFEQ\" width=\"640\"\u003E\u003C\/iframe\u003E\n\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EWatch on YouTube:\u0026nbsp;\u003Ca href=\"https:\/\/www.youtube.com\/watch?v=deTpicgkFEQ\" target=\"_blank\"\u003Ehttps:\/\/www.youtube.com\/watch?v=deTpicgkFEQ\u003C\/a\u003E\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EProgram Code: (PQueue.java)\u0026nbsp;\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\n\u003Ctr\u003E\u003Ctd\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eimport java.util.*;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003Epublic class PQueue {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; public static void main(String args[]) {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; Queue q = new PriorityQueue();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; int head;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(10);\u0026nbsp; \/\/offer()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(25);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(22);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; q.add(18);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; try{\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u0026nbsp; \/\/poll()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue: \" + q);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; head=(int)q.remove();\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; }\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;catch(Exception e) {\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; System.out.println(\"Queue is empty\");\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp;}\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp;}\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E}\u003C\/span\u003E\u003C\/td\u003E\u003C\/tr\u003E\n\u003C\/tbody\u003E\u003C\/table\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cbr \/\u003E\n\u003Cdiv dir=\"ltr\" style=\"orphans: auto; text-align: left; text-indent: 0px; widows: 1;\" trbidi=\"on\"\u003E\n\u003Cdiv style=\"font-family: 'times new roman';\"\u003E\n\u003Cdiv style=\"margin: 0px;\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EOutput:\u003C\/b\u003E\u003C\/span\u003E\u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Ctable border=\"1\"\u003E\u003Ctbody\u003E\n\u003Ctr\u003E\u003Ctd\u003E\u003Cdiv style=\"margin: 0px;\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog$ javac PQueue.java\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003ENote: PQueue.java uses unchecked or unsafe operations.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003ENote: Recompile with -Xlint:unchecked for details.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003Eparag@parag-Inspiron-N4010:~\/Desktop\/prog$ java PQueue\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: []\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 25, 22]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 18, 22, 25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [18, 25, 22]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [22, 25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: []\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue is empty\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/td\u003E\u003C\/tr\u003E\n\u003C\/tbody\u003E\u003C\/table\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cb style=\"font-size: x-large;\"\u003E\u003Cu\u003EExplanation:\u003C\/u\u003E\u003C\/b\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E1. Add 10\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-LcierGzXzYA\/XzJriWKZOkI\/AAAAAAAAEZQ\/CxsBqA_1Wa8RdNJMYF8B833rhQ3u_7_4QCNcBGAsYHQ\/s1600\/heap1.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"63\" data-original-width=\"69\" src=\"https:\/\/1.bp.blogspot.com\/-LcierGzXzYA\/XzJriWKZOkI\/AAAAAAAAEZQ\/CxsBqA_1Wa8RdNJMYF8B833rhQ3u_7_4QCNcBGAsYHQ\/s1600\/heap1.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E2. Add 25\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-f3H6ci7gBFo\/XzJrobVPdCI\/AAAAAAAAEZU\/B_rilJHuRkowyAgMi5boUnxdH5j8Dqb1ACNcBGAsYHQ\/s1600\/heap2.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"163\" data-original-width=\"135\" src=\"https:\/\/1.bp.blogspot.com\/-f3H6ci7gBFo\/XzJrobVPdCI\/AAAAAAAAEZU\/B_rilJHuRkowyAgMi5boUnxdH5j8Dqb1ACNcBGAsYHQ\/s1600\/heap2.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E3. Add 22\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-5XDL1QPfKKg\/XzJrw7uD73I\/AAAAAAAAEZY\/b4Wty9GZNVkSW1C8PczA6FJg-jsk0RB3ACNcBGAsYHQ\/s1600\/heap3.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"165\" data-original-width=\"189\" src=\"https:\/\/1.bp.blogspot.com\/-5XDL1QPfKKg\/XzJrw7uD73I\/AAAAAAAAEZY\/b4Wty9GZNVkSW1C8PczA6FJg-jsk0RB3ACNcBGAsYHQ\/s1600\/heap3.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 25, 22]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E4. Add 18\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-ha1h7Szqd3w\/XzJsdl2tnbI\/AAAAAAAAEZ0\/zwSJvdimIiYUvRXOlUL9xsCVJPTuBEflgCNcBGAsYHQ\/s1600\/heap4.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"274\" data-original-width=\"519\" src=\"https:\/\/1.bp.blogspot.com\/-ha1h7Szqd3w\/XzJsdl2tnbI\/AAAAAAAAEZ0\/zwSJvdimIiYUvRXOlUL9xsCVJPTuBEflgCNcBGAsYHQ\/s1600\/heap4.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [10, 18, 22, 25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E5. Remove next (head) element\u003C\/b\u003E\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-QRp5tohDNQk\/XzJtUbWHoBI\/AAAAAAAAEZ8\/WK_YvP2Ax3U6EdFA0hOCGOpZmnIvPr0yACNcBGAsYHQ\/s1600\/heap5.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"298\" data-original-width=\"917\" src=\"https:\/\/1.bp.blogspot.com\/-QRp5tohDNQk\/XzJtUbWHoBI\/AAAAAAAAEZ8\/WK_YvP2Ax3U6EdFA0hOCGOpZmnIvPr0yACNcBGAsYHQ\/s1600\/heap5.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [18, 25, 22]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E6. Remove next (head) element\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-pAr5p0i2BlQ\/XzJ2FSL5OgI\/AAAAAAAAEaY\/xBJjTJSmuEEVaUsBZD8hgZAofutNxo2wQCNcBGAsYHQ\/s1600\/heap6.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"193\" data-original-width=\"571\" src=\"https:\/\/1.bp.blogspot.com\/-pAr5p0i2BlQ\/XzJ2FSL5OgI\/AAAAAAAAEaY\/xBJjTJSmuEEVaUsBZD8hgZAofutNxo2wQCNcBGAsYHQ\/s1600\/heap6.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [22, 25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E7. Remove next (head) element\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"separator\" style=\"clear: both; text-align: center;\"\u003E\n\u003Ca href=\"https:\/\/1.bp.blogspot.com\/-9BjB41CaAoE\/XzJt8jzOYmI\/AAAAAAAAEaI\/k7ujrR1QHOUtv4_DfLEZA0F_k4e743R7QCNcBGAsYHQ\/s1600\/heap7.jpeg\" imageanchor=\"1\" style=\"margin-left: 1em; margin-right: 1em;\"\u003E\u003Cimg border=\"0\" data-original-height=\"196\" data-original-width=\"451\" src=\"https:\/\/1.bp.blogspot.com\/-9BjB41CaAoE\/XzJt8jzOYmI\/AAAAAAAAEaI\/k7ujrR1QHOUtv4_DfLEZA0F_k4e743R7QCNcBGAsYHQ\/s1600\/heap7.jpeg\" \/\u003E\u003C\/a\u003E\u003C\/div\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [25]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E8. Remove next (head) element\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003EQueue: [ ]\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comrevo.com\/feeds\/239714100273384946\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/priority-queue-in-java-using-heap.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/239714100273384946"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/239714100273384946"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/priority-queue-in-java-using-heap.html","title":"Priority Queue in Java | Priority Queue Using Heap | Priority Queue Implementation in Java"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/img.youtube.com\/vi\/deTpicgkFEQ\/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-913600556879440043.post-8591267448859644959"},"published":{"$t":"2020-08-07T18:06:00.000+05:30"},"updated":{"$t":"2020-08-07T18:06:07.589+05:30"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Computer Networks"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Java"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Networking"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Skill Development Lab"}],"title":{"type":"text","$t":"Fix \"java.net.BindException: Address already in use\" | bind exception in Java Socket Programming"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; \u0026nbsp; In this post, we will see\u0026nbsp;Fix \"java.net.BindException: Address already in use\" | bind exception in Java Socket Programming | Fix bind exception address already in use |\u0026nbsp; java.net.BindException | Java Socket Programming | bind exception address already in use,java.net.bindexception address already in use bind,the exception was java.net.bindexception address already in use bind,Exception in thread \"main\" java.net.BindException: Address already in use (Bind failed)\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003EWhen we rerun the socket program, we get following error:\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003EException in thread \"main\" java.net.BindException: Address already in use (Bind failed)\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003EFind solution for this exception (error) in this video:\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Ciframe allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\" frameborder=\"0\" height=\"360\" src=\"https:\/\/www.youtube.com\/embed\/DMoz4VwwJgg\" width=\"640\"\u003E\u003C\/iframe\u003E\n\n\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cbr \/\u003E\u003C\/span\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003E\u003Cbr \/\u003E\u003C\/b\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"font-size: large;\"\u003E\u003Cb\u003EWatch on YouTube:\u0026nbsp;\u003Ca href=\"https:\/\/www.youtube.com\/watch?v=DMoz4VwwJgg\" target=\"_blank\"\u003Ehttps:\/\/www.youtube.com\/watch?v=DMoz4VwwJgg\u003C\/a\u003E\u003C\/b\u003E\u003C\/span\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comrevo.com\/feeds\/8591267448859644959\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/fix-java-net-bind-exception-address-already-in-use.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/8591267448859644959"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/913600556879440043\/posts\/default\/8591267448859644959"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comrevo.com\/2020\/08\/fix-java-net-bind-exception-address-already-in-use.html","title":"Fix \"java.net.BindException: Address already in use\" | bind exception in Java Socket Programming"}],"author":[{"name":{"$t":"Parag Jambhulkar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/13991750622483538113"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"media$thumbnail":{"xmlns$media":"http://search.yahoo.com/mrss/","url":"https:\/\/img.youtube.com\/vi\/DMoz4VwwJgg\/default.jpg","height":"72","width":"72"},"thr$total":{"$t":"0"}}]}});