{"id":25524219,"date":"2022-05-14T12:00:43","date_gmt":"2022-05-14T06:30:43","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25524219"},"modified":"2022-11-20T08:58:55","modified_gmt":"2022-11-20T03:28:55","slug":"what-is-comparable-interface-in-java-with-examples","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/","title":{"rendered":"What is Comparable Interface in Java with Examples?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69e7ac2f984a5\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69e7ac2f984a5\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Super_Set_Sorting\" >Super Set Sorting<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Equals_Is_True\" >Equals Is True?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Ordering_by_Size\" >Ordering by Size<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Ordering_by_Name_Length\" >Ordering by Name Length<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Random_Number_Generator\" >Random Number Generator<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Checkerboard_Game_Board\" >Checkerboard Game Board<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Bubble_Sort\" >Bubble Sort<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Users_Choice_List\" >User&#8217;s Choice List<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Password_Validation\" >Password Validation<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#Online_Shopping_Cart\" >Online Shopping Cart<\/a><\/li><\/ul><\/nav><\/div>\n<p>Having been designed and developed by Sun Microsystems, Java is one of the most used programming languages across the globe. It has two types of interfaces \u2013 the Comparable interface and the Comparator interface. Both of these interfaces provide the functionality of comparing objects that implement it with other objects implementing it; however, their usage differs slightly in terms of implementation and execution. Let\u2019s take a look at these two interfaces in detail to understand what they are and how we can use them in our applications. <span data-slate-fragment=\"JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIydGV4dCUyMiUzQSUyMlRoZSUyMENvbXBhcmFibGUlMjBpbnRlcmZhY2UlMjBpbiUyMEphdmElMjBlbnN1cmVzJTIwdGhhdCUyMG9uZSUyMG9iamVjdCUyMGNhbiUyMGJlJTIwY29tcGFyZWQlMjB0byUyMGFub3RoZXIlMjBvYmplY3QlMjB3aXRoJTIwcmVzcGVjdCUyMHRvJTIwdGhlJTIwbmF0dXJhbCUyMG9yZGVyaW5nJTIwb2YlMjBpdHMlMjB1bmRlcmx5aW5nJTIwdHlwZSUyQyUyMHJlcHJlc2VudGVkJTIwYnklMjB0aGUlMjAlM0MlMjBvcGVyYXRvciUyMGluJTIwSmF2YS4lMjBJbiUyMHRoaXMlMjBhcnRpY2xlJTJDJTIwd2UlMjB3aWxsJTIwZXhwbG9yZSUyMDEwJTIwa2V5JTIwZXhhbXBsZXMlMjBhYm91dCUyMENvbXBhcmFibGUlMjBpbnRlcmZhY2UlMjBpbiUyMEphdmElMjB3aGljaCUyMHdpbGwlMjBoZWxwJTIweW91JTIwdW5kZXJzdGFuZCUyMGl0cyUyMGNvbmNlcHRzJTIwZWFzaWx5LiUyMiU3RCU1RCU3RCU1RA==\">The Comparable interface in Java ensures that one object can be compared to another object with respect to the natural ordering of its underlying type, represented by the &lt; operator in Java. In this article, we will explore 10 key examples of <a href=\"https:\/\/entri.app\/blog\/secure-coding-techniques-in-java-all-you-need-to-know\/\" target=\"_blank\" rel=\"noopener\">Comparable interfaces<\/a> in Java which will help you understand its concepts easily. The Comparable interface in Java basically compares the two objects by their values and then returns 0, 1 or -1 as the result of the comparison depending on whether the first object\u2019s value is less than, equal to or greater than the second object\u2019s value. The Comparable interface in Java makes sorting and comparing objects easier since you don\u2019t have to rely on hard-coded values and can simply rely on the return values from methods that implement this interface. These methods can be called directly from an application without the need for subclassing classes or implementing new interfaces.<\/span><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25522670 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png\" alt=\"Python and Machine Learning Rectangle\" width=\"970\" height=\"250\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png 970w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-300x77.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-768x198.png 768w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-750x193.png 750w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Super_Set_Sorting\"><\/span><strong>Super Set Sorting<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In an example of a Comparable interface, you will see how two types of objects can be sorted together. Suppose we have class Alpha which has field alpha1 and Alpha 2 which has field alpha2. Now suppose we want both of these classes to be used as part of set sorting (lets say) then we will make one class Comparable (implemented) and another extends one. So now when ever we need to sort a comparator object, then it will make use of comparable class object and they will follow every thing defined inside Comparable interface. Sorting can take place on same data type or different data type. For example if we are sorting String with String then it will go by alphabetical order of string. If we are sorting Integer with Integer then it will go by numerical order. This is all possible because of comparable interface. In our case here we<a href=\"https:\/\/entri.app\/blog\/secure-coding-techniques-in-java-all-you-need-to-know\/\" target=\"_blank\" rel=\"noopener\"> are comparing<\/a> two Alpha objects so that they can be sorted easily. We have created compareTo() method and inside that compareTo() method we have compared alpha1 and alpha2 fields with each other based on some criteria which is not important for us here. This is how its done! In our above example, if any argument passed to compareTo() method is null than compareTo() method returns 0 instead of throwing NullPointerException . But there is no rule for user defined class to implement it like that. User defined class should throw NullPointerException if any argument passed to compareTo() method is null . This behavior is not mandatory but most programmers do implement it like that. <span data-slate-fragment=\"JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIydGV4dCUyMiUzQSUyMlRoZSUyMENvbXBhcmFibGUlMjBpbnRlcmZhY2UlMjBpbiUyMEphdmElMjBhbGxvd3MlMjB5b3UlMjB0byUyMGNvbXBhcmUlMjB0d28lMjBvYmplY3RzJTJDJTIwc3VjaCUyMGFzJTIwdHdvJTIwZGlmZmVyZW50JTIwc3RyaW5nJTIwdmFsdWVzJTIwb3IlMjBldmVuJTIwdHdvJTIwZGlmZmVyZW50JTIwQnVzaW5lc3MlMjBPYmplY3RzJTJDJTIwYW5kJTIwdGhlbiUyMGdldCUyMGElMjByZXN1bHQlMjB0aGF0JTIwaW5kaWNhdGVzJTIwd2hldGhlciUyMHRoZSUyMHR3byUyMGNvbXBhcmVkJTIwb2JqZWN0cyUyMGFyZSUyMG9yZGVyZWQlMjBpbiUyMHRoZSUyMHNhbWUlMjB3YXklMjBvciUyMG5vdCUyQyUyMG9yJTIwaWYlMjB0aGV5JTIwYXJlJTIwb3JkZXJlZCUyMGluJTIwcmV2ZXJzZS4lMjBUaGlzJTIwY2FuJTIwYmUlMjB1c2VkJTIwdG8lMjBzb3J0JTIwYXJyYXlzJTIwb2YlMjBvYmplY3RzJTIwZWFzaWx5JTJDJTIwYnV0JTIwYWxzbyUyMHRvJTIwY2hlY2slMjB3aGV0aGVyJTIwb25lJTIwb2JqZWN0JTIwaXMlMjBncmVhdGVyJTIwdGhhbiUyMHRoZSUyMG90aGVyJTIwaW4lMjBzb21lJTIwd2F5LiUyMExldCVFMiU4MCU5OXMlMjBmaW5kJTIwb3V0JTIwaG93JTIweW91JTIwY2FuJTIwdXNlJTIwdGhpcyUyMGludGVyZmFjZSUyMGVmZmVjdGl2ZWx5JTIwaW4lMjB5b3VyJTIwSmF2YSUyMHByb2plY3RzISUyMiU3RCU1RCU3RCU1RA==\">The Comparable interface in Java allows you to compare two objects, such as two different string values or even two different Business Objects, and then get a result that indicates whether the two compared objects are ordered in the same way or not, or if they are ordered in reverse. This can be used to sort arrays of objects easily, but also to check whether one object is greater than the other in some way. Let\u2019s find out how you can use this interface effectively in your Java projects!<\/span><\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Equals_Is_True\"><\/span><strong>Equals Is True?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Equality is not a valid measure of sameness. Using String objects, you can have identical code that gives you three different answers based on how you look at things. For example, myString.equals(myString) will be true because myString and myString are equal (thanks to string interning), but myString == myString is false\u2014because those two strings point to two separate instances of String. If someone asks if your program works for strings that aren&#8217;t equivalent, that&#8217;s where <a href=\"https:\/\/entri.sng.link\/Bcofz\/uu8c\/w409\">using equals()<\/a> comes in handy; it compares your objects on an object-by-object basis rather than just trying to figure out if they&#8217;re pointing at the same place in memory. And as we&#8217;ve seen, equality doesn&#8217;t necessarily mean equivalence. In other words, these lines are all true: abc.equals(abc) abc.equals(ABC) abc.equals(ABCD) But if you use abcd.equals(abcd), it will return false! Why? Because while both strings contain the same characters in exactly the same order, each instance points to a different place in memory. <span data-slate-fragment=\"JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIydGV4dCUyMiUzQSUyMldoZXRoZXIlMjB5b3UlRTIlODAlOTlyZSUyMGFuJTIwZXhwZXJpZW5jZWQlMjBkZXZlbG9wZXIlMjBvciUyMGElMjBuZXdiaWUlMkMlMjBpdCVFMiU4MCU5OXMlMjBpbXBvcnRhbnQlMjB0byUyMGhhdmUlMjBhdCUyMGxlYXN0JTIwc29tZSUyMGJhc2ljJTIwdW5kZXJzdGFuZGluZyUyMG9mJTIwdGhlJTIwQ29tcGFyYWJsZSUyMGludGVyZmFjZSUyMGluJTIwSmF2YS4lMjBJZiUyMHlvdSUyMGRvbiVFMiU4MCU5OXQlMjBrbm93JTIwaG93JTIwdGhpcyUyMHVzZWZ1bCUyMHRvb2wlMjB3b3JrcyUyQyUyMHRoZW4lMjB5b3UlMjBjb3VsZCUyMGJlJTIwbWlzc2luZyUyMG91dCUyMG9uJTIwc29tZSUyMGdyZWF0JTIwZnVuY3Rpb25hbGl0eSUyMGluJTIweW91ciUyMGFwcGxpY2F0aW9ucyUyMGFuZCUyMHByb2plY3RzLiUyMFRoaXMlMjBhcnRpY2xlJTIwd2lsbCUyMHByb3ZpZGUlMjBhbiUyMGludHJvZHVjdGlvbiUyMHRvJTIwdGhlJTIwQ29tcGFyYWJsZSUyMGludGVyZmFjZSUyMGluJTIwSmF2YSUyQyUyMGFsb25nJTIwd2l0aCUyMHNldmVyYWwlMjBleGFtcGxlcyUyMG9mJTIwaG93JTIweW91JTIwY2FuJTIwdXNlJTIwaXQlMjB0byUyMGltcHJvdmUlMjB5b3VyJTIwcHJvZ3JhbSVFMiU4MCU5OXMlMjBwZXJmb3JtYW5jZSUyMGFuZCUyMGVmZmljaWVuY3kuJTIyJTdEJTVEJTdEJTVE\">Whether you\u2019re an experienced developer or a newbie, it\u2019s important to have at least some basic understanding of the Comparable interface in Java. If you don\u2019t know how this useful tool works, then you could be missing out on some great functionality in your applications and projects. This article will provide an introduction to the Comparable interface in Java, along with several examples of how you can use it to improve your program\u2019s performance and efficiency.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ordering_by_Size\"><\/span><strong>Ordering by Size<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Here is an example that lets you order books by size. When ordering an e-book, it might make sense to also list out its size in comparison with other books. To achieve that, you could create a Book class with a Size field, and use that when sorting books on your website. That way, if your users are ordering physical copies of books as well as e-books, they can still have their items listed by size. Note that you don\u2019t need to know how to code at all for any of these examples\u2014you just need to understand what\u2019s going on. This isn\u2019t meant to be used as instructions for writing code\u2014rather, think of it as an explanation for what different lines mean so that you can follow along more easily. If nothing else, these examples should help clear up some confusion about comparable interfaces in Java! For example, does it really matter whether or not we include null values? The answer is no!<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ordering_by_Name_Length\"><\/span><strong>Ordering by Name Length<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The Comparable interface contains two comparison methods you can use with strings, name().isOrderedBefore(String) and name().isOrderedAfter(String). Suppose you have a collection of names and want to sort them by length; you could use a comparable object as follows. Note that we needed both name() and compareTo() because using just one or another will not work correctly. The first element of c is Cecilia, so it should be ordered before all others. However, if we used only name(), then Catherina would come after Cecilia because they are equal under name(). But since Catherina comes after Cecilia alphabetically, it needs to come after her in our list too. So we need to call compareTo() on both elements. the java programming language allows for many types of user-defined classes. Among these are classes that model various kinds of numbers. This section provides an overview of how number classes work and some examples illustrating their usage. We\u2019ll begin with an overview of how numerical values behave in Java, followed by details about primitive types (integers, floating-point numbers, etc.) Next we\u2019ll look at reference types (objects), which represent numeric values within Java programs. We\u2019ll conclude with a discussion about class Math and its role within the java library for working with numeric values. As programmers familiarize themselves more deeply with any programming language, they discover new ways to express program logic concisely and accurately.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Random_Number_Generator\"><\/span><strong>Random Number Generator<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In an earlier example, we wrote a program that generates random integers using raw random() method. We will now improve on that design by using a separate Random object. The advantages of doing so include better control over seed values and support for concurrent threads. A disadvantage is increased initial complexity but once it\u2019s set up, its easier to use, especially if you are generating many random numbers or doing something with those numbers after they have been generated (such as statistics gathering or simulations). Code Sample 5-1 shows how to do just that. Just by looking at it, can you determine why it might be advantageous? Which class and method are executed concurrently? In general, what are some ways you could make your own program more thread safe? What would you need to consider? If these questions don\u2019t jump out at you right away, take a moment to think about them before moving on. The answers may not come easily, but don\u2019t worry\u2014we\u2019ll revisit them later in Part III when we talk about concurrency in detail.<\/p>\n<p style=\"text-align: center;\"><strong><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\">Learn Coding in your Language! Enroll Here!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Checkerboard_Game_Board\"><\/span><strong>Checkerboard Game Board<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>This example shows how Comparable interface can be used while sorting numbers. The concept is simple. You have a checkerboard board with a defined number of rows and columns. Each cell is assigned a unique id, which helps us in sorting these cells based on their respective row and column position. To make it interesting, we&#8217;ll add logic for exchanging two cells (based on their ids) if they are equal. Note that each cell can only belong to one row or one column at any given time. If a cell changes its position from one row\/column to another, it should take its new position&#8217;s unique id as its <a href=\"https:\/\/entri.app\/blog\/secure-coding-techniques-in-java-all-you-need-to-know\/\" target=\"_blank\" rel=\"noopener\">current identifier<\/a> (or vice versa). We&#8217;ll start off by defining our class variables. The first thing we need to do is define a function that will assign an ID to each of our cells. In order to do so, we need a list of integers. For now, let&#8217;s just create an array with four integers: 0 , 1 , 2 , 3 . We can then use those values as keys when creating new Cell objects inside our main() method. Next up, let&#8217;s create an array called cells and assign it all zeros except for 0, which gets set to 1 . That way, when we loop through our array later on, every element other than 0 will automatically get set to zero because arrays are zero-indexed.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Bubble_Sort\"><\/span><strong>Bubble Sort<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>This sorting algorithm is considered inefficient, but it has its merits. Bubble sort works by comparing each pair of items. If one item is less than or equal to another, no bubble will be created; however, if one value is greater than another, a bubble is made with that pair inside. The bubbles are then sorted and moved up (or down) accordingly until they disappear into their <a href=\"https:\/\/entri.app\/blog\/secure-coding-techniques-in-java-all-you-need-to-know\/\" target=\"_blank\" rel=\"noopener\">appropriate bin<\/a>. The algorithm moves as quickly as possible until it finishes without any swaps or other fancy operations to speed things up. Although bubble sort has its uses\u2014and can even outperform some algorithms in certain situations\u2014its lack of efficiency makes it a poor choice for many applications where time matters. For instance, bubble sort could be a good option for high school students learning about sorting techniques. <span data-slate-fragment=\"JTVCJTdCJTIydHlwZSUyMiUzQSUyMnBhcmFncmFwaCUyMiUyQyUyMmNoaWxkcmVuJTIyJTNBJTVCJTdCJTIydGV4dCUyMiUzQSUyMlRoZSUyMENvbXBhcmFibGUlMjBpbnRlcmZhY2UlMjB3YXMlMjBpbnRyb2R1Y2VkJTIwaW4lMjBKYXZhJTIwU0UlMjA4JTIwdG8lMjBhbGxvdyUyMHRoZSUyMHByb2dyYW1tZXIlMjB0byUyMHNwZWNpZnklMjBjdXN0b20lMjBuYXR1cmFsJTIwb3JkZXJpbmclMjByZWxhdGlvbnNoaXAlMjBvZiUyMG9iamVjdHMlMjBpbiUyMGN1c3RvbSUyMGNsYXNzZXMlMjAob3IlMjBpbnRlcmZhY2VzKS4lMjBTaW1pbGFyJTIwdG8lMjBob3clMjB5b3UlMjBjYW4lMjB1c2UlMjB0aGUlMjBDb21wYXJhdG9yJTIwaW50ZXJmYWNlJTIwdG8lMjBkZWZpbmUlMjB0aGUlMjBzb3J0JTIwb3JkZXIlMjB3aGVuJTIwc29ydGluZyUyMGFuJTIwYXJyYXklMjBvciUyMGxpc3QlMkMlMjB5b3UlMjBjYW4lMjB1c2UlMjBDb21wYXJhYmxlJTIwdG8lMjBkZWZpbmUlMjB0aGUlMjBzb3J0JTIwb3JkZXIlMjB3aGVuJTIwdXNpbmclMjBDb2xsZWN0aW9ucyUyMEFQSSUyMHNvcnRpbmclMjBtZXRob2RzJTIwc3VjaCUyMGFzJTIwQ29sbGVjdGlvbnMuc29ydCgpJTIwLiUyMFRvJTIwZG8lMjBzbyUyQyUyMGZpcnN0JTIweW91JTIwbmVlZCUyMHRvJTIwaW1wbGVtZW50JTIwdGhlJTIwQ29tcGFyYWJsZSUyMGludGVyZmFjZSUyMGFuZCUyMHRoZW4lMjBkZWNsYXJlJTIwdGhhdCUyMHlvdXIlMjBjbGFzcyUyMHN1cHBvcnRzJTIwY29tcGFyaXNvbnMlMjBpbiUyMGl0cyUyMEFQSSUyMGRvY3VtZW50YXRpb24uJTIyJTdEJTVEJTdEJTVE\">The Comparable interface was introduced in Java SE 8 to allow the programmer to specify custom natural ordering relationship of objects in custom classes (or interfaces). Similar to how you can use the Comparator interface to define the sort order when sorting an array or list, you can use Comparable to define the sort order when using Collections API sorting methods such as Collections.sort() . To do so, first you need to implement the Comparable interface and then declare that your class supports comparisons in its API documentation.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Users_Choice_List\"><\/span><strong>User&#8217;s Choice List<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Create a list of user&#8217;s choices with GUI, where each item has a corresponding option which can be selected. In case of an invalid entry, users can correct it and resubmit or proceed without correction. Show how your design is robust against null values from user inputs. Another challenge is implementing pagination for data sets that are too large to fit on one screen (such as playing a movie). Provide solution code that supports up and down keys (or buttons) on the keyboard while displaying current page number and total pages in UI. Make sure that your solution also handle cases when data set isn&#8217;t<a href=\"https:\/\/entri.app\/blog\/10-tips-to-help-you-stand-out-as-a-java-developer\/\" target=\"_blank\" rel=\"noopener\"> sorted properly<\/a> using default sorting method (eg. alphabetical order), so that items are displayed in proper order. The key point here is to show you have thought about all possible use cases and have prepared for them by providing solutions. Remember, most interviewers aren&#8217;t looking at whether you got it right; they&#8217;re looking at whether you thought about all possible scenarios before coding anything! So don&#8217;t just jump into coding; think first! It&#8217;s better to take some time upfront thinking through various edge-cases than taking hours trying to debug something later on because you didn&#8217;t think about all possible use-cases during development!<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><strong>Learn to code from industry experts! Enroll here<\/strong><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Password_Validation\"><\/span><strong>Password Validation<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>When creating a password policy for your system, you may want to validate whether passwords meet certain requirements. For example, passwords should be at least eight characters long and should contain one letter and one number. If they don\u2019t, they might get rejected. To implement such validation logic, you can write code that compares an object\u2019s value with specific criteria <a href=\"https:\/\/entri.app\/blog\/solid-design-principle-java-an-overview\/\" target=\"_blank\" rel=\"noopener\">by implementing<\/a> Comparable interface. There are multiple overloads of compareTo() method available in Comparable interface which accepts parameters of type int , long , float , double , char &amp; String . All these parameters except String take values as non-negative constants i.e., valid range or actual value instead of null references indicating not acceptable input value for given parameter.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Online_Shopping_Cart\"><\/span><strong>Online Shopping Cart<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The shopping cart application is a personal information manager (PIM) or an online shopping cart software that allows consumers to combine different items and checkout online at once. The functionality of a shopping cart can be compared with a physical shopping cart found in retail stores but has key differences. A physical store\u2019s shopping carts are usually located near each of its cash registers, making it easy for customers to purchase items individually. Physical stores do not make it <a href=\"https:\/\/entri.app\/blog\/secure-coding-techniques-in-java-all-you-need-to-know\/\" target=\"_blank\" rel=\"noopener\">convenient for<\/a> customers to go back and check out more products at a later time because they only have one physical cart available per register. Online, however, there are no barriers between visitors and their chosen products as they can add different items as many times as they want without having restrictions on inventory space. If you are interested to learn new coding skills, the Entri app will help you to acquire them very easily. Entri app is following a structural study plan so that the students can learn very easily. If you don&#8217;t have a coding background, it won&#8217;t be any problem. You can download the Entri app from the google play store and enroll in your favorite course.<a href=\"https:\/\/bit.ly\/3ELmCiA\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-25522670 size-full\" src=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png\" alt=\"Python and Machine Learning Rectangle\" width=\"970\" height=\"250\" srcset=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1.png 970w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-300x77.png 300w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-768x198.png 768w, https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/04\/Python-and-Machine-Learning-Rectangle-1-750x193.png 750w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Having been designed and developed by Sun Microsystems, Java is one of the most used programming languages across the globe. It has two types of interfaces \u2013 the Comparable interface and the Comparator interface. Both of these interfaces provide the functionality of comparing objects that implement it with other objects implementing it; however, their usage [&hellip;]<\/p>\n","protected":false},"author":93,"featured_media":25524222,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1864,1882,1883,1881],"tags":[],"class_list":["post-25524219","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-data-science-ml","category-java-programming","category-react-native","category-web-android-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>What is Comparable Interface in Java with Examples? - Entri Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"What is Comparable Interface in Java with Examples? - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"Having been designed and developed by Sun Microsystems, Java is one of the most used programming languages across the globe. It has two types of interfaces \u2013 the Comparable interface and the Comparator interface. Both of these interfaces provide the functionality of comparing objects that implement it with other objects implementing it; however, their usage [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-05-14T06:30:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-11-20T03:28:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Akhil M G\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Akhil M G\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/\"},\"author\":{\"name\":\"Akhil M G\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6\"},\"headline\":\"What is Comparable Interface in Java with Examples?\",\"datePublished\":\"2022-05-14T06:30:43+00:00\",\"dateModified\":\"2022-11-20T03:28:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/\"},\"wordCount\":2482,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png\",\"articleSection\":[\"Articles\",\"Data Science and Machine Learning\",\"Java Programming\",\"React Native\",\"Web and Android Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/\",\"url\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/\",\"name\":\"What is Comparable Interface in Java with Examples? - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png\",\"datePublished\":\"2022-05-14T06:30:43+00:00\",\"dateModified\":\"2022-11-20T03:28:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png\",\"width\":820,\"height\":615,\"caption\":\"What is Comparable Interface in Java with Examples?\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Entri Skilling\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Java Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"What is Comparable Interface in Java with Examples?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6\",\"name\":\"Akhil M G\",\"url\":\"https:\/\/entri.app\/blog\/author\/akhil\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"What is Comparable Interface in Java with Examples? - Entri Blog","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:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/","og_locale":"en_US","og_type":"article","og_title":"What is Comparable Interface in Java with Examples? - Entri Blog","og_description":"Having been designed and developed by Sun Microsystems, Java is one of the most used programming languages across the globe. It has two types of interfaces \u2013 the Comparable interface and the Comparator interface. Both of these interfaces provide the functionality of comparing objects that implement it with other objects implementing it; however, their usage [&hellip;]","og_url":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2022-05-14T06:30:43+00:00","article_modified_time":"2022-11-20T03:28:55+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png","type":"image\/png"}],"author":"Akhil M G","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Akhil M G","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/"},"author":{"name":"Akhil M G","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6"},"headline":"What is Comparable Interface in Java with Examples?","datePublished":"2022-05-14T06:30:43+00:00","dateModified":"2022-11-20T03:28:55+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/"},"wordCount":2482,"commentCount":0,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png","articleSection":["Articles","Data Science and Machine Learning","Java Programming","React Native","Web and Android Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/","url":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/","name":"What is Comparable Interface in Java with Examples? - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png","datePublished":"2022-05-14T06:30:43+00:00","dateModified":"2022-11-20T03:28:55+00:00","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2022\/05\/Untitled-39-1.png","width":820,"height":615,"caption":"What is Comparable Interface in Java with Examples?"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/what-is-comparable-interface-in-java-with-examples\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Entri Skilling","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/"},{"@type":"ListItem","position":3,"name":"Java Programming","item":"https:\/\/entri.app\/blog\/category\/entri-skilling\/java-programming\/"},{"@type":"ListItem","position":4,"name":"What is Comparable Interface in Java with Examples?"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/875646423b2cce93c1bd5bc16850fff6","name":"Akhil M G","url":"https:\/\/entri.app\/blog\/author\/akhil\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25524219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/93"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25524219"}],"version-history":[{"count":6,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25524219\/revisions"}],"predecessor-version":[{"id":25547536,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25524219\/revisions\/25547536"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25524222"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25524219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25524219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25524219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}