{"id":13486,"date":"2020-03-18T15:25:24","date_gmt":"2020-03-18T22:25:24","guid":{"rendered":"https:\/\/careerkarma.com\/blog\/?p=13486"},"modified":"2023-12-01T02:33:20","modified_gmt":"2023-12-01T10:33:20","slug":"java-recursion","status":"publish","type":"post","link":"https:\/\/careerkarma.com\/blog\/java-recursion\/","title":{"rendered":"How to Use Recursion in Java"},"content":{"rendered":"\n<p>In programming, recursion refers to the process in which a function calls itself directly or indirectly. Recursion is used to solve a number of problems in computer science.<br><\/p>\n\n\n\n<p>The Java programming language supports creating recursive methods, which are methods that call themselves.<br><\/p>\n\n\n\n<p>In this tutorial, we are going to discuss, with reference to examples, how recursion works, and how you can create a recursive function in Java. After reading this guide, you\u2019ll be an expert at writing recursive methods in Java.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Methods<\/h2>\n\n\n\n<p>Methods, sometimes called functions, are blocks of code that perform a specific task. For instance, a method could be used to calculate the sum of an array of values or print out the contents of an array to the console.<br><\/p>\n\n\n\n<p>Here\u2019s the syntax for a method in Java:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>modifier static returnType methodName (Parameters) {\n\t\/\/ Method body\n}\n<\/pre><\/div>\n\n\n\n<p>For instance, suppose you wanted to create a method that printed out the sentence \u201cIt\u2019s Wednesday! We\u2019re half-way through the week!\u201d to the console. You could do so using this code:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Main {\npublic static void printItsWednesday() {\n\tSystem.out.println(\"It's Wednesday! We're half-way through the week!\");\n}\npublic static void main(String[] args) {\n\tprintItsWednesday();\n}\n}\n<\/pre><\/div>\n\n\n\n<p>When we call this method using <code>printItsWednesday()<\/code>, the following is returned:<br><\/p>\n\n\n\n<p>It\u2019s Wednesday! We\u2019re half-way through the week!<br><\/p>\n\n\n\n<p>If you\u2019re interested in learning more about Java methods, you can read our complete guide to methods in Java here.<br><\/p>\n\n\n\n<p>In our above example, we call the <code>prinItsWednesday() <\/code>method in the main program. But if we were to call our method in the method itself, we would have created a recursive method.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Recursion<\/h2>\n\n\n\n<p>Recursive methods are methods that are called within the main method at first and then are called within the method itself. Here\u2019s the syntax for a recursive method:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>static void executeMethod() {\n\t\/\/ Code here\n\texecuteMethod(); \/\/ This is our recursive call\n\t\/\/ Code here\n}\npublic static void main(String[] args) {\n\texecuteMethod(); \/\/ This is the normal method call\n}\n<\/pre><\/div>\n\n\n\n<p>When we run our program, the <code>executeMethod() <\/code>method is called in our main program. This causes the code in the <code>executeMethod()<\/code> method to be run, which in this case includes the <code>executeMethod()<\/code> method. So, when our program runs, it will enter a loop.<br><\/p>\n\n\n\n<p>The program will continue executing the <code>executeMethod() <\/code>method until a condition is met that prevents it from continuing. If no conditions are specified that could stop the recursion, the program will run on forever. This is referred to as infinite recursion.<br><\/p>\n\n\n\n<p>Why should you use recursion? First, recursion can reduce the time complexity of a program in certain cases. Second, recursion can make it easier for you to implement some algorithms in a more readable and maintainable way.<br><\/p>\n\n\n\n<p>Here are a few examples of programs which are often written using recursion:<br><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Calculating the fibonacci sequence<\/li>\n\n\n\n<li>Reversing a string<\/li>\n\n\n\n<li>Calculating a factorial of a number<\/li>\n\n\n\n<li>Calculating the height of a binary tree<\/li>\n<\/ul>\n\n\n\n<p>That said, recursion can be slower than writing a standard method to perform a task. This is because recursion creates a new storage location for variables every time a recursive method is executed.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Java Recursion Examples<\/h2>\n\n\n\n<p>Let\u2019s walk through two examples to demonstrate how recursion works in Java.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reversing a String Using Recursion<\/h3>\n\n\n\n<p>Suppose we are building a program for a middle school teacher that reverses a string with each student\u2019s grades throughout the year. The string starts with the first grade the student received and ends with the most recent grade the student has earned. We want to reverse the string so the last, or most recent, grade earned by the student is first in the string.<br><\/p>\n\n\n\n<p>We could use the following code to reverse the string:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>public class ReverseGrades {\n\tpublic static String reverse(String grades) {\n\t\tif (grades.isEmpty())\n\t\t\treturn grades;\n\t\treturn reverse(grades.substring(1)) + grades.charAt(0);\n\t}\n\tpublic static void main(String[] args) {\n\t\tString grades = \"CBCBAABACAABA\";\n\t\tString reverse_grades = reverse(grades);\n\t\tSystem.out.println(\"This student's grades for the year are: \" + reverse_grades);\n\t}\n}\n<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p>This student\u2019s grades for the year are: <code>ABAACABAABCBC<\/code><br><\/p>\n\n\n\n<p>As you can see, our program has reversed the contents of our string. In our program, we have created a recursive function called <code>reverse()<\/code>.<br><\/p>\n\n\n\n<p>When the <code>reverse()<\/code> function is executed, first check if the grades string is empty. If it is, we return the list of grades to the main program. This stops the recursion because the <code>reverse()<\/code> call at the end of the function is not given the chance to run.<br><\/p>\n\n\n\n<p>If the grades string is not empty, our program will execute the <code>reverse()<\/code> method again and concatenate the result of the function to the first character of the sentence. We use the <code>charAt()<\/code> method in our example to retrieve the first character in the sentence, and add it to the left side of the <code>reverse()<\/code> method.<br><\/p>\n\n\n\n<p>After our string has been reversed, a message stating <code>This student\u2019s grades for the year are:<\/code> \u201c, followed by the reversed string of student grades, is returned to the program.<br><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Calculating a Factorial Using Recursion<\/h3>\n\n\n\n<p>Another instance where recursion can be useful is in calculating the factorial of a number.<br><\/p>\n\n\n\n<p>In math, factorials are the product of all positive integers less than or equal to a number multiplied together. For instance, the factorial of 5 is equal to 5*4*3*2*1, which is 120. Because factorial methods involve a repetitive calculation, they are a good real-life example of where recursion can be useful in solving a problem.<br><\/p>\n\n\n\n<p>The following Java program allows us to calculate a factorial of the number 7 in Java:<br><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre>class Main {\n\tstatic int calculateFactorial(int number) {\n\t\tif (number != 0)\n\t\t\treturn number * calculateFactorial(number-1);\n\t\telse\n\t\t\treturn 1;\n\t}\n\t\n\tpublic static void main(String[] args) {\n\t\tint num = 7;\n\t\tint answer = calculateFactorial(num);\n\t\tSystem.out.println(\"The factorial of 7 is: \" + answer);\n\t}\n}<\/pre><\/div>\n\n\n\n<p>Our code returns:<br><\/p>\n\n\n\n<p><code>The factorial of 7 is: 5040<br><\/code><\/p>\n\n\n\n<p>In this example, we create a method called <code>calculateFactorial()<\/code> that multiplies the number stored in the number parameter by the result of the next <code>calculateFactorial()<\/code> method. This process executes until the number parameter is equal to 0.<br><\/p>\n\n\n\n<p>When the number parameter is equal to 0, the if statement in our code returns 1 and the result of the <code>calculateFactorial()<\/code> method is passed back to the main program.<br><\/p>\n\n\n\n<p>So, the <code>calculateFactorial()<\/code> method performs 7*6*5*4*3*2*1, then returns the answer to the main program. Once the answer has been calculated, the message <code>The factorial of 7 is:<\/code> , followed by the answer calculated by our program, is printed to the console.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Recursion is a concept in programming used to describe a method that calls itself. Recursive methods can be useful in cases where you need to repeat a task multiple times over and use the result of the previous iteration of that task in the current iteration.<br><\/p>\n\n\n\n<p>This tutorial walked through the basics of recursion in Java and how to create recursive methods. In addition, this tutorial walked through two examples of recursion in action, with reference to reversing a string and calculating a factorial.<br><\/p>\n\n\n\n<p>You\u2019re now ready to start working with recursive methods in Java like a professional!<\/p>\n","protected":false},"excerpt":{"rendered":"In programming, recursion refers to the process in which a function calls itself directly or indirectly. Recursion is used to solve a number of problems in computer science. The Java programming language supports creating recursive methods, which are methods that call themselves. In this tutorial, we are going to discuss, with reference to examples, how&hellip;","protected":false},"author":240,"featured_media":13487,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[17289],"tags":[],"class_list":{"0":"post-13486","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-java"},"acf":{"post_sub_title":"","sprint_id":"","query_class":"Java","school_sft":"","parent_sft":"","school_privacy_policy":"","has_review":"","is_sponser_post":"","is_guest_post":""},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.0 (Yoast SEO v27.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Use Recursion in Java: The Complete Guide | Career Karma<\/title>\n<meta name=\"description\" content=\"Code recursion is the process in which a function calls itself. Learn how to build recursive functions in your Java code on Career Karma.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/careerkarma.com\/blog\/java-recursion\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use Recursion in Java\" \/>\n<meta property=\"og:description\" content=\"Code recursion is the process in which a function calls itself. Learn how to build recursive functions in your Java code on Career Karma.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/careerkarma.com\/blog\/java-recursion\/\" \/>\n<meta property=\"og:site_name\" content=\"Career Karma\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/facebook.com\/careerkarmaapp\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-18T22:25:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-12-01T10:33:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"667\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"James Gallagher\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@career_karma\" \/>\n<meta name=\"twitter:site\" content=\"@career_karma\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"James Gallagher\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/\"},\"author\":{\"name\":\"James Gallagher\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"headline\":\"How to Use Recursion in Java\",\"datePublished\":\"2020-03-18T22:25:24+00:00\",\"dateModified\":\"2023-12-01T10:33:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/\"},\"wordCount\":993,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg\",\"articleSection\":[\"Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-recursion\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/\",\"name\":\"How to Use Recursion in Java: The Complete Guide | Career Karma\",\"isPartOf\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg\",\"datePublished\":\"2020-03-18T22:25:24+00:00\",\"dateModified\":\"2023-12-01T10:33:20+00:00\",\"author\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\"},\"description\":\"Code recursion is the process in which a function calls itself. Learn how to build recursive functions in your Java code on Career Karma.\",\"breadcrumb\":{\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/careerkarma.com\/blog\/java-recursion\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg\",\"width\":1000,\"height\":667},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/careerkarma.com\/blog\/java-recursion\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog\",\"item\":\"https:\/\/careerkarma.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\/\/careerkarma.com\/blog\/java\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Use Recursion in Java\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#website\",\"url\":\"https:\/\/careerkarma.com\/blog\/\",\"name\":\"Career Karma\",\"description\":\"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/careerkarma.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94\",\"name\":\"James Gallagher\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"contentUrl\":\"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg\",\"caption\":\"James Gallagher\"},\"description\":\"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.\",\"url\":\"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Use Recursion in Java: The Complete Guide | Career Karma","description":"Code recursion is the process in which a function calls itself. Learn how to build recursive functions in your Java code on Career Karma.","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:\/\/careerkarma.com\/blog\/java-recursion\/","og_locale":"en_US","og_type":"article","og_title":"How to Use Recursion in Java","og_description":"Code recursion is the process in which a function calls itself. Learn how to build recursive functions in your Java code on Career Karma.","og_url":"https:\/\/careerkarma.com\/blog\/java-recursion\/","og_site_name":"Career Karma","article_publisher":"http:\/\/facebook.com\/careerkarmaapp","article_published_time":"2020-03-18T22:25:24+00:00","article_modified_time":"2023-12-01T10:33:20+00:00","og_image":[{"width":1000,"height":667,"url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg","type":"image\/jpeg"}],"author":"James Gallagher","twitter_card":"summary_large_image","twitter_creator":"@career_karma","twitter_site":"@career_karma","twitter_misc":{"Written by":"James Gallagher","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/#article","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/"},"author":{"name":"James Gallagher","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"headline":"How to Use Recursion in Java","datePublished":"2020-03-18T22:25:24+00:00","dateModified":"2023-12-01T10:33:20+00:00","mainEntityOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/"},"wordCount":993,"commentCount":0,"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg","articleSection":["Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/careerkarma.com\/blog\/java-recursion\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/","url":"https:\/\/careerkarma.com\/blog\/java-recursion\/","name":"How to Use Recursion in Java: The Complete Guide | Career Karma","isPartOf":{"@id":"https:\/\/careerkarma.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage"},"image":{"@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage"},"thumbnailUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg","datePublished":"2020-03-18T22:25:24+00:00","dateModified":"2023-12-01T10:33:20+00:00","author":{"@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94"},"description":"Code recursion is the process in which a function calls itself. Learn how to build recursive functions in your Java code on Career Karma.","breadcrumb":{"@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/careerkarma.com\/blog\/java-recursion\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/#primaryimage","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/03\/close-up-of-computer-screen-325111-1.jpg","width":1000,"height":667},{"@type":"BreadcrumbList","@id":"https:\/\/careerkarma.com\/blog\/java-recursion\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog","item":"https:\/\/careerkarma.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/careerkarma.com\/blog\/java\/"},{"@type":"ListItem","position":3,"name":"How to Use Recursion in Java"}]},{"@type":"WebSite","@id":"https:\/\/careerkarma.com\/blog\/#website","url":"https:\/\/careerkarma.com\/blog\/","name":"Career Karma","description":"Latest Coding Bootcamp News &amp; Career Hacks from Industry Insiders","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/careerkarma.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/e79364792443fbff794a144c67ec8e94","name":"James Gallagher","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/careerkarma.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","contentUrl":"https:\/\/careerkarma.com\/blog\/wp-content\/uploads\/2020\/01\/james-gallagher-150x150.jpg","caption":"James Gallagher"},"description":"James Gallagher is a self-taught programmer and the technical content manager at Career Karma. He has experience in range of programming languages and extensive expertise in Python, HTML, CSS, and JavaScript. James has written hundreds of programming tutorials, and he frequently contributes to publications like Codecademy, Treehouse, Repl.it, Afrotech, and others.","url":"https:\/\/careerkarma.com\/blog\/author\/jamesgallagher\/"}]}},"_links":{"self":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/users\/240"}],"replies":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/comments?post=13486"}],"version-history":[{"count":0,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/posts\/13486\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media\/13487"}],"wp:attachment":[{"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/media?parent=13486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/categories?post=13486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/careerkarma.com\/blog\/wp-json\/wp\/v2\/tags?post=13486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}