

{"id":10347,"date":"2018-03-09T10:07:24","date_gmt":"2018-03-09T10:07:24","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=10347"},"modified":"2026-05-22T18:17:55","modified_gmt":"2026-05-22T12:47:55","slug":"java-comparator-interface","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/","title":{"rendered":"Java Comparator Interface &#8211; Working of Collections.Sort()"},"content":{"rendered":"<p>When we work with user-defined classes in Java, there may have been some kind of a need to arrange data in a proper way. However, since the data is user-defined, there is absolutely no way for built-in functions to arrange these elements.<\/p>\n<p>Moreover, if there is a specific condition for arranging these data, then we need to have a different method inside the class. To avoid these kinds of problems, Java has an interface known as the Comparator Interface.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-84506 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg\" alt=\"Java Comparator Interface\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java-1024x536.jpg 1024w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java-720x377.jpg 720w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java-520x272.jpg 520w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java-320x167.jpg 320w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><\/p>\n<h3>Comparator Interface in Java<\/h3>\n<p>When you need to order the data items of a user-defined data, i.e, classes, then you can use the comparator interface. It can prove to be fruitful when you need a data item based on a specific condition that would differ from user to user.<\/p>\n<p><strong>There are two primary methods in the Java Comparator Interface:<\/strong><\/p>\n<p><strong>1. public int compare(Object ob1, Object b2):<\/strong>\u00a0This function has the responsibility of comparing any two objects and returns an integer value based on it. This method returns -1,0,1 to say that it is either less than, equal to, or greater than the other object.<\/p>\n<p><strong>2. public boolean equals(Object obj):<\/strong>\u00a0This method is particularly useful for checking whether the current object is exactly equal to the second object.<\/p>\n<p><strong>3. static &lt;T&gt; Comparator&lt;T&gt; nullsFirst(Comparator&lt;? super T&gt; comparator):<\/strong>\u00a0This function essentially compares objects. However, it takes into consideration that nulls are less than non-null elements.<\/p>\n<p><strong>4. static &lt;T&gt; Comparator&lt;T&gt; nullsLast(Comparator&lt;? super T&gt; comparator):<\/strong>\u00a0This is similar to the nullsLast comparator except for a fundamental difference. This method takes into consideration that nulls are greater than non-null elements in the collection.<\/p>\n<h3>How does the Sort Method in the Java Collection Sort Work?<\/h3>\n<ul>\n<li>Whenever we need to sort the values in a collection, this \u201csort\u201d method transfers control to the compare method in the class.<\/li>\n<li>The compare method then returns some values based on the comparison.<\/li>\n<li>It returns 0 if both objects are equal.<\/li>\n<li>This returns 1 if the first object is greater than the second.<\/li>\n<li>It returns -1 if the second object is greater than the first.<\/li>\n<li>Using these values, the function decides whether to swap the values for the sorting process.<\/li>\n<\/ul>\n<p><strong>Java program to illustrate the use of Comparator Interface(Old Style &#8211; Without generics):<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.dataflair.comparatorinterface;\r\nimport java.util.ArrayList;\r\nimport java.util.Collections;\r\nimport java.util.Comparator;\r\nimport java.util.List;\r\n\r\nclass Cars\r\n\r\n{\r\n    \/\/this is the class that defines the properties of a car object.\r\n    \/\/The car would have a name. A type. and an ID. \r\n    String name;\r\n    String type;\r\n    long ID;\r\n\r\n    Cars(String name, String type, long ID)\r\n    {\r\n        this.name=name;\r\n        this.type=type;\r\n        this.ID=ID;\r\n    }\r\n}\r\nclass NameComparator implements Comparator\r\n{\r\n\r\n    @Override\r\n    public int compare(Object o1, Object o2) {\r\n        \/\/ TODO Auto-generated method stub\r\n        Cars c2=(Cars)o2;\r\n        Cars c1=(Cars)o1;\r\n        return c1.name.compareTo(c2.name);\r\n    }\r\n}\r\nclass TypeComparator implements Comparator\r\n{\r\n    @Override\r\n    public int compare(Object o1, Object o2)\r\n    {\r\n        Cars c2=(Cars)o2;\r\n        Cars c1=(Cars)o1;\r\n        return c1.type.compareTo(c2.type);\r\n    }\r\n}\r\n\r\npublic class Base {\r\n    public static void main(String[] args) {\r\n\r\n        List&lt;Cars&gt; carslist = new ArrayList&lt;&gt;();\r\n        carslist.add(new Cars(\"Viper\",\"Sports\",1125412342l));\r\n        carslist.add(new Cars(\"Supra\",\"Sports\",1244560087l));\r\n        carslist.add(new Cars(\"Royce\",\"Sedan\",1111412341l));\r\n        carslist.add(new Cars(\"Patriot\",\"OffRoad\",9831441244l));\r\n\r\n        System.out.println(\"The cars before sorting\\n\\n\");\r\n        carslist.forEach((car)-&gt;System.out.println(car.name+\" \"+car.type+\" \"+car.ID));\r\n\r\n        \/\/Now we sort by the name\r\n        Collections.sort(carslist, new NameComparator());\r\n\r\n        System.out.println(\"\\n\\nThe cars after sorting by the car names\\n\\n\");\r\n        carslist.forEach((car)-&gt;System.out.println(car.name+\" \"+car.type+\" \"+car.ID));\r\n\r\n        System.out.println(\"\\n\\nThe cars after sorting them by their type\\n\\n\");\r\n\r\n        \/\/Now we sort the values by their type. \r\n        Collections.sort(carslist,new TypeComparator());\r\n\r\n        carslist.forEach((car)-&gt;System.out.println(car.name+\" \"+car.type+\" \"+car.ID));\r\n        \r\n    }\r\n    \r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">The cars before sortingViper Sports 1125412342<br \/>\nSupra Sports 1244560087<br \/>\nRoyce Sedan 1111412341<br \/>\nPatriot OffRoad 9831441244The cars after sorting by the car namesPatriot OffRoad 9831441244<br \/>\nRoyce Sedan 1111412341<br \/>\nSupra Sports 1244560087<br \/>\nViper Sports 1125412342The cars after sorting them by their typePatriot OffRoad 9831441244<br \/>\nRoyce Sedan 1111412341<br \/>\nSupra Sports 1244560087<br \/>\nViper Sports 1125412342<\/p>\n<\/div>\n<p><strong>Java program to illustrate the use of Comparator Interface(New style- With generics):<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">package com.dataflair.comparatorinterface;\r\nimport java.util.*;\r\n\r\n\r\npublic class Human\r\n{\r\n    String name;\r\n    int age;\r\n    Human()\r\n    {\r\n        name=\"NoName\";\r\n        age=0;\r\n    }\r\n    Human(String name, int age)\r\n    {\r\n        this.name=name;\r\n        this.age=age;\r\n\r\n    }\r\n    public String getName() {\r\n        return name;\r\n    }\r\n    public int getAge() {\r\n        return age;\r\n    }\r\n    public void setAge(int age) {\r\n        this.age = age;\r\n    }\r\n    public void setName(String name) {\r\n        this.name = name;    \r\n    }\r\n\r\n    public static Comparator&lt;Human&gt; ageComparator=new Comparator&lt;Human&gt;()\r\n    {\r\n        public int compare(Human h1, Human h2)\r\n        {\r\n            return h1.getAge()-h2.getAge();\r\n        }\r\n    };\r\n\r\n    public static Comparator&lt;Human&gt; nameComparator=new Comparator&lt;Human&gt;()\r\n    {\r\n        public int compare(Human h1, Human h2)\r\n        {\r\n            return h1.getName().compareTo(h2.getName());\r\n        }\r\n    };\r\n\r\npublic static void main(String[] args) {\r\n    ArrayList&lt;Human&gt; humans = new ArrayList&lt;&gt;();\r\n    humans.add(new Human(\"Shraman\", 21));\r\n    humans.add(new Human(\"Shubham\", 23));\r\n    humans.add(new Human(\"Pranav\", 20));\r\n    humans.add(new Human(\"Srijan\", 19));\r\n    humans.add(new Human(\"Gourav\", 24));\r\n    humans.add(new Human(\"Amit\", 11));\r\n    humans.add(new Human(\"Raju\", 41));\r\n\r\n    System.out.println(\"Before sorting\");\r\n    humans.forEach((n)-&gt; System.out.print(n.name+\" \"+n.age+\" \\n\"));\r\n\r\n    System.out.println(\"\\n After Sorting by age\");\r\n    Collections.sort(humans, ageComparator );\r\n    humans.forEach((n)-&gt; System.out.print(n.name+\" \"+n.age+\" \\n\"));\r\n\r\n    System.out.println(\"\\n After sorting by Name\");\r\n    \r\n    Collections.sort(humans, nameComparator );\r\n    humans.forEach((n)-&gt; System.out.print(n.name+\" \"+n.age+\" \\n\"));\r\n}\r\n\r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Before sorting<br \/>\nShraman 21<br \/>\nShubham 23<br \/>\nPranav 20<br \/>\nSrijan 19<br \/>\nGourav 24<br \/>\nAmit 11<br \/>\nRaju 41After Sorting by age<br \/>\nAmit 11<br \/>\nSrijan 19<br \/>\nPranav 20<br \/>\nShraman 21<br \/>\nShubham 23<br \/>\nGourav 24<br \/>\nRaju 41After sorting by Name<br \/>\nAmit 11<br \/>\nGourav 24<br \/>\nPranav 20<br \/>\nRaju 41<br \/>\nShraman 21<br \/>\nShubham 23<br \/>\nSrijan 19<\/div>\n<p>As we can observe, the comparator method is an easier method of arranging the data items according to a particular logic. Point to note is that this example corresponds to the new way of using Java generics to implement individual comparators for.<\/p>\n<h3>Basic Differences between Comparable and Comparator in Java<\/h3>\n<p>1. The comparable interface can only be useful for sorting the elements in a class in a single way. However, the comparator interface is useful for sorting multiple types of data in a class.<\/p>\n<p>2. While using comparable Interfaces, the class itself has to implement the interface. However, we may choose to implement or not implement the Comparator interface in the base class. You can take advantage of anonymous classes in Java to leverage this issue.<\/p>\n<p>3. While using the Comparable interface, we do not need to make any changes to the code. This is because the sort functions of the Collections class automatically use the compareTo method in the class. However, while we implement the Comparator interface, we need to use the comparator name along with the sort function.<\/p>\n<p>4. The java.lang houses the Comparable interface, whereas the java. util package contains the Comparator interface. You have to be cautious while using interfaces because you would run into errors if you do not import the correct package.<\/p>\n<p>5. When it comes to simple sorting, then Comparable is the best fit for it. But if the program needed various classes for sorting, or the sorting is complex, then opting for the Comparator is best.<\/p>\n<p>6. To sort the elements based on certain criteria or to define the sorting, a Comparator should be chosen.<\/p>\n<p>7. If the work is about achieving flexibility, it is recommended to go with the Comparator.<\/p>\n<h3>Rules for Using Comparator Interface in Java<\/h3>\n<p>There are certain rules that you should keep in mind before actually attempting to implement an interface. Some of them are:<\/p>\n<ul>\n<li>You can use the Comparator interface to sort the elements of the collection.<\/li>\n<li>If you keep your object type as undefined while implementing the Comparator Interface, then you need to make sure that you typecast all the variables inside it to the Object inside the method.<\/li>\n<li>You need to specify the generic of the user datatype while passing it to a comparator. If you do not, then Java converts it to an Object type by default. You would not be able to compare individual elements after that.<\/li>\n<\/ul>\n<h3>Choosing Between Comparable and Comparator in Java<\/h3>\n<p>When it comes to sorting objects, Comparable and Comparator offer different trade-offs. Comparable is ideal for sorting by a single field within a class, keeping the sorting logic organized and directly tied to the class itself. On the other hand, Comparator shines for multiple criteria or sorting across classes. It provides more flexibility by creating reusable sorting objects that can be applied to different scenarios, potentially improving code maintainability in the long run.<\/p>\n<h3>Summary<\/h3>\n<p>In this article, we came to know about the various uses of the comparator interface. We also came to know about the process of using Comparator Interfaces in programs to structure classes easily. We now know the comparable interface and the comparator interface, and how they are different from each other. This is a very popular question in interviews.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When we work with user-defined classes in Java, there may have been some kind of a need to arrange data in a proper way. However, since the data is user-defined, there is absolutely no&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":84506,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32],"tags":[2721,7436,7437,7438,16248],"class_list":["post-10347","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java","tag-comparator-interface-in-java","tag-java-comparator","tag-java-comparator-example","tag-java-comparator-interface","tag-working-of-collections-sort"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java Comparator Interface - Working of Collections.Sort() - DataFlair<\/title>\n<meta name=\"description\" content=\"Java Comparator Interface,Java Comparator example,what is Comparator Interface in Java,Working of Collections.Sort(),Comparator Interface Java\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java Comparator Interface - Working of Collections.Sort() - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Java Comparator Interface,Java Comparator example,what is Comparator Interface in Java,Working of Collections.Sort(),Comparator Interface Java\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-03-09T10:07:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-22T12:47:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java Comparator Interface - Working of Collections.Sort() - DataFlair","description":"Java Comparator Interface,Java Comparator example,what is Comparator Interface in Java,Working of Collections.Sort(),Comparator Interface Java","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/","og_locale":"en_US","og_type":"article","og_title":"Java Comparator Interface - Working of Collections.Sort() - DataFlair","og_description":"Java Comparator Interface,Java Comparator example,what is Comparator Interface in Java,Working of Collections.Sort(),Comparator Interface Java","og_url":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-03-09T10:07:24+00:00","article_modified_time":"2026-05-22T12:47:55+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Java Comparator Interface &#8211; Working of Collections.Sort()","datePublished":"2018-03-09T10:07:24+00:00","dateModified":"2026-05-22T12:47:55+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/"},"wordCount":1017,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg","keywords":["Comparator Interface in Java","Java Comparator","Java Comparator example","Java Comparator Interface","Working of Collections.Sort()"],"articleSection":["Java Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/","url":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/","name":"Java Comparator Interface - Working of Collections.Sort() - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg","datePublished":"2018-03-09T10:07:24+00:00","dateModified":"2026-05-22T12:47:55+00:00","description":"Java Comparator Interface,Java Comparator example,what is Comparator Interface in Java,Working of Collections.Sort(),Comparator Interface Java","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/java-comparator-interface\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/03\/Comparator-Interface-in-Java.jpg","width":1200,"height":628,"caption":"Comparator Interface in Java"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/java-comparator-interface\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Java Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/java\/"},{"@type":"ListItem","position":3,"name":"Java Comparator Interface &#8211; Working of Collections.Sort()"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/10347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=10347"}],"version-history":[{"count":12,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/10347\/revisions"}],"predecessor-version":[{"id":148432,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/10347\/revisions\/148432"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/84506"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=10347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=10347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=10347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}