{"id":14886,"date":"2023-12-21T15:54:29","date_gmt":"2023-12-21T10:24:29","guid":{"rendered":"https:\/\/www.h2kinfosys.com\/blog\/?p=14886"},"modified":"2025-02-20T02:13:07","modified_gmt":"2025-02-20T07:13:07","slug":"how-to-use-pairs-in-java","status":"publish","type":"post","link":"https:\/\/www.h2kinfosys.com\/blog\/how-to-use-pairs-in-java\/","title":{"rendered":"Mastering Pairs in Java: 5 Ways to Create and Utilize Them Efficiently!"},"content":{"rendered":"\n<p>Java is one of the most widely used programming languages globally, known for its simplicity, reliability, and versatility. If you\u2019re pursuing a <strong><a href=\"https:\/\/www.h2kinfosys.com\/courses\/java-online-training-course-details\/\">Java Certification<\/a><\/strong> or enrolling in <strong>online Java courses<\/strong>, understanding how to use pairs effectively is a fundamental skill you\u2019ll want to master. This guide explores the concept of pairs in Java, their applications, and practical implementation with real-world examples.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What Are Pairs in Java?<\/strong><\/h2>\n\n\n\n<p><strong>Pairs in Java<\/strong> is a simple data structure that holds <strong>two related values<\/strong> together, often referred to as a <strong>key-value pair<\/strong>. While Java does not provide a built-in <code>Pair<\/code> class, various third-party libraries, such as <strong>Apache Commons Lang<\/strong> and <strong>JavaFX<\/strong>, offer implementations.<\/p>\n\n\n\n<p>Pairs are particularly useful when a <strong>method needs to return two values<\/strong> or when working with <strong>data relationships<\/strong> that involve two associated elements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Key Features of Pairs<\/strong><\/h3>\n\n\n\n<p>&#x2705; <strong>Two Elements<\/strong>: Each pair consists of <strong>two values<\/strong>, often labeled as <code>first<\/code> and <code>second<\/code>.<br>&#x2705; <strong>Data Type Flexibility<\/strong>: Can store any combination of <strong>data types<\/strong>, such as <code>Integer-String<\/code>, <code>String-Double<\/code>, or <code>Object-Object<\/code>.<br>&#x2705; <strong>Utility<\/strong>: Used in various <strong>algorithms, data structures, and relational data mappings<\/strong> for efficient programming.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Use Pairs in Java?<\/strong><\/h2>\n\n\n\n<p>Understanding the <strong>practical applications<\/strong> of pairs in Java can significantly enhance your <strong>Java programming skills<\/strong>, especially when working on <strong>real-world projects<\/strong>. Here\u2019s why using pairs is beneficial:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1&#xfe0f;&#x20e3; Code Simplification<\/strong><\/h3>\n\n\n\n<p>&#x1f539; Eliminates the need to create <strong>custom classes<\/strong> for storing simple key-value relationships.<br>&#x1f539; Makes the code <strong>more concise, readable, and manageable<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2&#xfe0f;&#x20e3; Versatility in Data Structures<\/strong><\/h3>\n\n\n\n<p>&#x1f539; Easily integrates with <strong>Java Collections<\/strong> like <code>List<\/code>, <code>Map<\/code>, and <code>Set<\/code>.<br>&#x1f539; Provides a <strong>lightweight<\/strong> alternative to more complex data structures.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3&#xfe0f;&#x20e3; Efficiency in Development<\/strong><\/h3>\n\n\n\n<p>&#x1f539; Reduces <strong>boilerplate code<\/strong> by providing a <strong>ready-to-use data structure<\/strong>.<br>&#x1f539; Improves <strong>readability and maintainability<\/strong> in situations where a structured key-value representation is needed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Common Use Cases of Pairs in Java<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1&#xfe0f;&#x20e3; Returning Two Values from a Function<\/strong><\/h3>\n\n\n\n<p>A common scenario where pairs in Java are useful is when a function needs to return <strong>two different values<\/strong> without creating a dedicated class.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java<code>import javafx.util.Pair;\n\npublic class PairExample {\n    public static Pair&lt;Integer, String> getStudentInfo() {\n        return new Pair&lt;>(101, \"John Doe\");\n    }\n\n    public static void main(String&#91;] args) {\n        Pair&lt;Integer, String> student = getStudentInfo();\n        System.out.println(\"Student ID: \" + student.getKey());\n        System.out.println(\"Student Name: \" + student.getValue());\n    }\n}\n<\/code><\/code><\/pre>\n\n\n\n<p>&#x2705; <strong>Advantage<\/strong>: Avoids the need for a separate class while keeping the code <strong>clean and efficient<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2&#xfe0f;&#x20e3; Representing Relationships in Graph Algorithms<\/strong><\/h3>\n\n\n\n<p>Graph-based problems often require <strong>storing node relationships<\/strong>, and pairs provide a convenient way to represent <strong>edges<\/strong>.<\/p>\n\n\n\n<p><strong>Example: Representing an Edge in a Graph<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java<code>import javafx.util.Pair;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class GraphExample {\n    public static void main(String&#91;] args) {\n        List&lt;Pair&lt;Integer, Integer>> edges = new ArrayList&lt;>();\n        edges.add(new Pair&lt;>(1, 2));\n        edges.add(new Pair&lt;>(2, 3));\n        edges.add(new Pair&lt;>(3, 4));\n\n        for (Pair&lt;Integer, Integer> edge : edges) {\n            System.out.println(\"Edge: \" + edge.getKey() + \" -> \" + edge.getValue());\n        }\n    }\n}\n<\/code><\/code><\/pre>\n\n\n\n<p>&#x2705; <strong>Advantage<\/strong>: Simplifies graph representations, making it <strong>easy to store and manipulate edges<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3&#xfe0f;&#x20e3; Storing Mappings in Caching Mechanisms<\/strong><\/h3>\n\n\n\n<p>Pairs in Java are frequently used in <strong>caching systems<\/strong> to store <strong>temporary key-value mappings<\/strong>, such as a <strong>user session with expiration time<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4&#xfe0f;&#x20e3; Sorting and Filtering Data<\/strong><\/h3>\n\n\n\n<p>Pairs are useful in <strong>sorting algorithms<\/strong>, particularly when <strong>multiple criteria<\/strong> are involved.<\/p>\n\n\n\n<p><strong>Example: Sorting Based on Values<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java<code>import javafx.util.Pair;\nimport java.util.*;\n\npublic class SortingExample {\n    public static void main(String&#91;] args) {\n        List&lt;Pair&lt;String, Integer>> scores = new ArrayList&lt;>();\n        scores.add(new Pair&lt;>(\"Alice\", 85));\n        scores.add(new Pair&lt;>(\"Bob\", 92));\n        scores.add(new Pair&lt;>(\"Charlie\", 78));\n\n        scores.sort(Comparator.comparing(Pair::getValue)); \/\/ Sorting by score\n\n        for (Pair&lt;String, Integer> entry : scores) {\n            System.out.println(entry.getKey() + \": \" + entry.getValue());\n        }\n    }\n}\n<\/code><\/code><\/pre>\n\n\n\n<p>&#x2705; <strong>Advantage<\/strong>: Makes sorting operations simpler when dealing with <strong>rankings or leaderboards<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Advantages of Using Pairs in Java<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&#x1f539; Code Simplification<\/strong><\/h3>\n\n\n\n<p>Pairs in Java help eliminate <strong>unnecessary boilerplate code<\/strong>, making the logic <strong>more concise and readable<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&#x1f539; Flexibility with Data Types<\/strong><\/h3>\n\n\n\n<p>Pairs can hold <strong>heterogeneous data<\/strong>, meaning you can pair <strong>any two objects<\/strong> together.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&#x1f539; Lightweight &amp; Efficient<\/strong><\/h3>\n\n\n\n<p>Using a <code>Pair<\/code> is <strong>faster and more memory-efficient<\/strong> than creating <strong>custom classes<\/strong> for simple use cases.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&#x1f539; Easy Integration with Collections<\/strong><\/h3>\n\n\n\n<p>Pairs can be <strong>easily stored in Lists, Maps, and Sets<\/strong>, making them <strong>highly versatile<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Performance Considerations<\/strong><\/h2>\n\n\n\n<p>While pairs <strong>simplify development<\/strong>, there are a few performance trade-offs to keep in mind:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&#x1f538; Memory Overhead<\/strong><\/h3>\n\n\n\n<p>Using pairs <strong>introduces a small memory footprint<\/strong>, as they are <strong>wrapper objects<\/strong> around primitive types. For performance-critical applications, using <strong>arrays<\/strong> or <strong>custom classes<\/strong> may be more efficient.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&#x1f538; Mutability vs. Immutability<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Immutable Pairs<\/strong>: <strong>Thread-safe<\/strong>, but require creating <strong>new objects<\/strong> for modifications.<\/li>\n\n\n\n<li><strong>Mutable Pairs<\/strong>: Allow updates but may introduce <strong>unintended side effects<\/strong> if shared across threads.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&#x1f538; Readability in Large Applications<\/strong><\/h3>\n\n\n\n<p>For <strong>complex business logic<\/strong>, defining <strong>explicit classes<\/strong> can <strong>improve code clarity<\/strong> rather than using generic pairs everywhere.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Implementing a Custom Pair Class in Java<\/strong><\/h2>\n\n\n\n<p>Since Java does not have a built-in <code>Pair<\/code> class, you can create your own:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>java<code>public class Pair&lt;F, S> {\n    private final F first;\n    private final S second;\n\n    public Pair(F first, S second) {\n        this.first = first;\n        this.second = second;\n    }\n\n    public F getFirst() {\n        return first;\n    }\n\n    public S getSecond() {\n        return second;\n    }\n\n    @Override\n    public String toString() {\n        return \"(\" + first + \", \" + second + \")\";\n    }\n}\n<\/code><\/code><\/pre>\n\n\n\n<p>&#x2705; <strong>Advantage<\/strong>: Provides <strong>full control<\/strong> over the implementation and customization.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Create and Use Pairs in Java<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Option 1: Using JavaFX Pair Class<\/h3>\n\n\n\n<p>JavaFX provides a built-in <code>Pair<\/code> class in the <code>javafx.util<\/code> package. Here\u2019s how you can use it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import javafx.util.Pair;\n\npublic class PairExample {\n    public static void main(String&#91;] args) {\n        Pair&lt;String, Integer&gt; pair = new Pair&lt;&gt;(\"Apple\", 10);\n\n        \/\/ Access elements\n        System.out.println(\"Key: \" + pair.getKey());\n        System.out.println(\"Value: \" + pair.getValue());\n    }\n}<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Key: Apple\nValue: 10<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Option 2: Using Apache Commons Lang Library<\/h3>\n\n\n\n<p>The Apache Commons Lang library offers a <code>Pair<\/code> implementation with more flexibility.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Add Maven Dependency<\/h3>\n\n\n\n<p>Include the following dependency in your <code>pom.xml<\/code> file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;dependency&gt;\n    &lt;groupId&gt;org.apache.commons&lt;\/groupId&gt;\n    &lt;artifactId&gt;commons-lang3&lt;\/artifactId&gt;\n    &lt;version&gt;3.12.0&lt;\/version&gt;\n&lt;\/dependency&gt;<\/code><\/pre>\n\n\n\n<p>Step 2: Implement the Pair<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import org.apache.commons.lang3.tuple.Pair;\n\npublic class PairExampleApache {\n    public static void main(String&#91;] args) {\n        Pair&lt;String, Double&gt; pair = Pair.of(\"Banana\", 0.99);\n\n        \/\/ Access elements\n        System.out.println(\"Item: \" + pair.getLeft());\n        System.out.println(\"Price: \" + pair.getRight());\n    }\n}<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Item: Banana\nPrice: 0.99<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Real-World Applications of Pairs<\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Returning Multiple Values from a Method<\/strong><\/h3>\n\n\n\n<p>Sometimes, you may need to return two values from a method. Pairs simplify this task.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import javafx.util.Pair;\n\npublic class ReturnPair {\n\n    public static Pair&lt;String, Integer&gt; getStudentInfo() {\n        return new Pair&lt;&gt;(\"John Doe\", 25);\n    }\n\n    public static void main(String&#91;] args) {\n        Pair&lt;String, Integer&gt; student = getStudentInfo();\n        System.out.println(\"Name: \" + student.getKey());\n        System.out.println(\"Age: \" + student.getValue());\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">2. <strong>Storing Key-Value Mappings in Collections<\/strong><\/h2>\n\n\n\n<p>Pairs can be used in collections like <code>List<\/code> or <code>Set<\/code> for relational data.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import javafx.util.Pair;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class PairInCollections {\n    public static void main(String&#91;] args) {\n        List&lt;Pair&lt;String, String&gt;&gt; countries = new ArrayList&lt;&gt;();\n        countries.add(new Pair&lt;&gt;(\"USA\", \"Washington, D.C.\"));\n        countries.add(new Pair&lt;&gt;(\"France\", \"Paris\"));\n\n        for (Pair&lt;String, String&gt; country : countries) {\n            System.out.println(country.getKey() + \" - \" + country.getValue());\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Advanced Use Cases for Pairs<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>Pairs in Graph Algorithms<\/strong><\/h3>\n\n\n\n<p>Pairs are often used to represent edges in graph algorithms, where the pair holds the source and destination nodes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import javafx.util.Pair;\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class GraphPairs {\n    public static void main(String&#91;] args) {\n        List&lt;Pair&lt;Integer, Integer&gt;&gt; edges = new ArrayList&lt;&gt;();\n        edges.add(new Pair&lt;&gt;(1, 2));\n        edges.add(new Pair&lt;&gt;(2, 3));\n\n        for (Pair&lt;Integer, Integer&gt; edge : edges) {\n            System.out.println(\"Edge: \" + edge.getKey() + \" -&gt; \" + edge.getValue());\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>Pairs in Sorting<\/strong><\/h3>\n\n\n\n<p>Pairs can help in sorting tasks where you want to sort elements based on one value while keeping the associated value.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import javafx.util.Pair;\nimport java.util.ArrayList;\nimport java.util.Collections;\nimport java.util.Comparator;\nimport java.util.List;\n\npublic class SortPairs {\n    public static void main(String&#91;] args) {\n        List&lt;Pair&lt;String, Integer&gt;&gt; items = new ArrayList&lt;&gt;();\n        items.add(new Pair&lt;&gt;(\"Apple\", 5));\n        items.add(new Pair&lt;&gt;(\"Banana\", 3));\n        items.add(new Pair&lt;&gt;(\"Cherry\", 8));\n\n        \/\/ Sort by quantity\n        items.sort(Comparator.comparing(Pair::getValue));\n\n        for (Pair&lt;String, Integer&gt; item : items) {\n            System.out.println(item.getKey() + \" - \" + item.getValue());\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Types of Pair Classes<\/strong><\/h2>\n\n\n\n<p>Java has two different kinds of Pair classes, which are as follows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Immutable Pair Class<\/strong>: These classes prevent an object&#8217;s value from changing once it has been defined; hence, we are unable to modify defined values using the setters function. If the value is defined, it usually won&#8217;t change.<\/li>\n\n\n\n<li><strong>Mutable Pair Class<\/strong>: We can change the value of a mutable class at any point during the program. The getters and setters methods allow us to access and modify an object&#8217;s value. Even if we defined the values at the beginning of the program, we may change them later on. The object value can be set and accessed using the pair.setValue(a,b) and pair.getValue() methods.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why do We Need Pair Class<\/strong><\/h2>\n\n\n\n<p>To retrieve the value in a key pair combination, utilise the pair class. Stated differently, the methods in the pair class return two values together. We may utilise the Pair class for a variety of reasons.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>A few situations in which we must utilise the Pair class are as follows:<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Let&#8217;s say we wish to provide more than one value. Although we may accomplish this by utilising data structures like Arrays and HashMaps, it might become challenging to return both of them when working with a cluster of variables at once. The Pair class will come in extremely handy in these situations.<\/li>\n\n\n\n<li>The Pair class makes it simple to display the result of a mathematical operation combined with the number that was calculated.<\/li>\n\n\n\n<li>In the event that we wish to work with a tree data structure.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Using Pairs in Java<\/h2>\n\n\n\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>Use Descriptive Names<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Avoid generic names like <code>first<\/code> and <code>second<\/code>. Use <code>key<\/code> and <code>value<\/code> or other meaningful terms.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Choose the Right Library<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Depending on your project, choose between JavaFX and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Apache\" rel=\"nofollow noopener\" target=\"_blank\">Apache<\/a> Commons Lang.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Avoid Overuse<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Use pairs for lightweight tasks. For more complex structures, define custom classes.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Read and Learn<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Where to Start:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Java Beginners<\/strong>: If you are just starting out, focus on the basics of Pairs using JavaFX.<\/li>\n\n\n\n<li><strong>Advanced Learners<\/strong>: Dive into Apache Commons Lang for more robust and scalable implementations.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Next Steps:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Explore practical code examples shared above.<\/li>\n\n\n\n<li>Experiment with integrating Pairs in Java into your own projects.<\/li>\n\n\n\n<li>Learn about related data structures like Maps and Tuples.<\/li>\n<\/ul>\n\n\n\n<p>For more structured guidance, H2K Infosys offers detailed tutorials and hands-on training.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Key Takeaways<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Pairs are versatile and simplify code when dealing with two related values.<\/li>\n\n\n\n<li>JavaFX and Apache Commons Lang offer robust implementations of pairs.<\/li>\n\n\n\n<li>Use pairs for returning multiple values, representing key-value mappings, and relational data storage.<\/li>\n<\/ul>\n\n\n\n<p>For a hands-on approach to mastering pairs and other Java concepts, enroll in our <a href=\"https:\/\/www.h2kinfosys.com\/blog\/tag\/java-programming-language\/\" data-type=\"post_tag\" data-id=\"392\"><strong>J<\/strong>ava Programming Language<\/a> free course or check out our <strong>online Java learning<\/strong> programs at H2K Infosys. Equip yourself with industry-relevant skills and achieve your java<strong> certification<\/strong> goals.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Using pairs in Java is an essential skill for simplifying and streamlining your code. Whether you&#8217;re managing key-value mappings, returning multiple values, or enhancing data structures, pairs offer a clean and efficient solution. Explore the versatility of JavaFX and Apache Commons Lang libraries to implement pairs effectively in your projects.<\/p>\n\n\n\n<p>Take the next step in your Java journey. Join <strong><a href=\"https:\/\/www.h2kinfosys.com\/\">H2K Infosys<\/a><\/strong> today for comprehensive, hands-on learning in Java and achieve your certification goals with confidence!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java is one of the most widely used programming languages globally, known for its simplicity, reliability, and versatility. If you\u2019re pursuing a Java Certification or enrolling in online Java courses, understanding how to use pairs effectively is a fundamental skill you\u2019ll want to master. This guide explores the concept of pairs in Java, their applications, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[42],"tags":[695,1998,1999,1997],"class_list":["post-14886","post","type-post","status-publish","format-standard","hentry","category-java-tutorials","tag-certification","tag-java-certification","tag-java-programming","tag-pairs-in-java"],"_links":{"self":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/14886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/comments?post=14886"}],"version-history":[{"count":0,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/posts\/14886\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/media?parent=14886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/categories?post=14886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.h2kinfosys.com\/blog\/wp-json\/wp\/v2\/tags?post=14886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}