{"id":354,"date":"2024-03-03T17:48:05","date_gmt":"2024-03-03T17:48:05","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/java\/?p=354"},"modified":"2024-03-03T17:48:05","modified_gmt":"2024-03-03T17:48:05","slug":"advanced-java-what-is-reflection","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/java\/advanced-java-what-is-reflection\/","title":{"rendered":"Advanced Java &#8211; What is Reflection?"},"content":{"rendered":"<p>In this tutorial, you will learn about Reflection in Java and how to use it.<\/p>\n<ol>\n<li><a href=\"#t1\">Overview of Java Reflection<a><\/li>\n<li><a href=\"#t2\">How Java Reflection Works<\/a><\/li>\n<li><a href=\"#t3\">Benefits of Java Reflection<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t1\">1. Overview of Reflection in Java<\/strong><\/h4>\n<p>Reflection means a program looking at itself and accessing it&#8217;s properties. It is an advance Java programming feature that allows the program to manipulate it&#8217;s internal properties at run time.<\/p>\n<p>For example, a class in Java can use reflection to obtain all the member variables and methods. This information can be obtained even if those variables and methods are private or final.<\/p>\n<p>As you know, you cannot access private methods from outside a class. However, with reflection you can now access those private methods.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t2\">2. How Java Reflection Works<\/strong><\/h4>\n<p>Below are example how refection use-cases:<\/p>\n<p><strong>Retrieving the fields of a class<\/strong><\/p>\n<p>In the code below we provide a class with private fields and methods.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">class<\/span> <span style=\"color: #bb0066; font-weight: bold;\">Car<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\r\n\t<span style=\"color: #008800; font-weight: bold;\">private<\/span> String model<span style=\"color: #333333;\">;<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> available <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">8<\/span><span style=\"color: #333333;\">;<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #0066bb; font-weight: bold;\">Car<\/span><span style=\"color: #333333;\">(<\/span>String model<span style=\"color: #333333;\">,<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> available<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">model<\/span> <span style=\"color: #333333;\">=<\/span> model<span style=\"color: #333333;\">;<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">this<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">available<\/span> <span style=\"color: #333333;\">=<\/span> available<span style=\"color: #333333;\">;<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">int<\/span> <span style=\"color: #0066bb; font-weight: bold;\">getAvailable<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t<span style=\"color: #008800; font-weight: bold;\">return<\/span> available<span style=\"color: #333333;\">;<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">start<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Engine started and runing...\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">private<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">move<\/span><span style=\"color: #333333;\">()<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Gear engages, accelerating...\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>In the main method below, we instantiate our car class and then use reflection to retrieve and print out all the fields of the class.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #008800; font-weight: bold;\">static<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">main<\/span><span style=\"color: #333333;\">(<\/span>String<span style=\"color: #333333;\">[]<\/span> args<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\t\t\r\n\tCar myCar <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> Car<span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"Toyota Camry\"<\/span><span style=\"color: #333333;\">,<\/span> <span style=\"color: #0000dd; font-weight: bold;\">9<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\r\n\tprint<span style=\"color: #333333;\">(<\/span>car<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">name<\/span><span style=\"color: #333333;\">);<\/span> <span style=\"color: #888888;\">\/\/ Error: name is not visible<\/span>\r\n\t\r\n\t<span style=\"color: #888888;\">\/\/Now using reflection<\/span>\r\n\tField<span style=\"color: #333333;\">[]<\/span> carFields <span style=\"color: #333333;\">=<\/span> myCar<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getClass<\/span><span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">getDeclaredFields<\/span><span style=\"color: #333333;\">();<\/span>\r\n\t\r\n\t<span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span>Field <span style=\"color: #997700; font-weight: bold;\">field:<\/span> carFields<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span>field<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getName<\/span><span style=\"color: #333333;\">());<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>If you execute the main() method above then<\/p>\n<ul>\n<li>model<\/li>\n<li>available<\/li>\n<\/ul>\n<p>would be printed to the console<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Setting the private field of a class<\/strong><\/p>\n<p>In the main method below, we set the values of the model using reflection.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span>Field <span style=\"color: #997700; font-weight: bold;\">field:<\/span> carFields<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>field<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getName<\/span><span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">equals<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"model\"<\/span><span style=\"color: #333333;\">))<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tfield<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setAccessible<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t\tfield<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">set<\/span><span style=\"color: #333333;\">(<\/span>myCar<span style=\"color: #333333;\">,<\/span> <span style=\"background-color: #fff0f0;\">\"Range Rover\"<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\t\t\t\r\nSystem<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">out<\/span><span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">println<\/span><span style=\"color: #333333;\">(<\/span>myCar<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getModel<\/span><span style=\"color: #333333;\">());<\/span>\r\n<\/pre>\n<p>This code actually changes the value of the private field <strong><em>model<\/em><\/strong> from &#8220;Toyota Camry&#8221; to &#8220;Range Rover&#8221;.<\/p>\n<p>Note: I added a public getModel() method to the car class to be able to print this value to the output.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Calling a private method<\/strong><\/p>\n<p>In the code below we use reflection to call a private method.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">Method<span style=\"color: #333333;\">[]<\/span> carMethods <span style=\"color: #333333;\">=<\/span> myCar<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getClass<\/span><span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">getDeclaredMethods<\/span><span style=\"color: #333333;\">();<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">for<\/span><span style=\"color: #333333;\">(<\/span>Method <span style=\"color: #997700; font-weight: bold;\">method:<\/span> carMethods<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\tmethod<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">setAccessible<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #008800; font-weight: bold;\">true<\/span><span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #008800; font-weight: bold;\">if<\/span><span style=\"color: #333333;\">(<\/span>method<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">getName<\/span><span style=\"color: #333333;\">().<\/span><span style=\"color: #0000cc;\">equals<\/span><span style=\"color: #333333;\">(<\/span><span style=\"background-color: #fff0f0;\">\"start\"<\/span><span style=\"color: #333333;\">))<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\t\tmethod<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">invoke<\/span><span style=\"color: #333333;\">(<\/span>myCar<span style=\"color: #333333;\">);<\/span>\r\n\t<span style=\"color: #333333;\">}<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\t\r\n<\/pre>\n<p>Note that the invoke() method takes the instance of the object as a parameter.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Calling a static method<\/strong><\/p>\n<p>This is similar to call a non-static method with the difference that the invoke() would take null as parameter if the method being invoked is static.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Calling a method with parameters<\/strong><\/p>\n<p>In this case, you will pass the arguments to the invoke() method following the first argument which will always be the name of the instance. Of course, all the parameters are comma-separated.<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id=\"t3\">3. Benefits\/Uses of Reflection<\/strong><\/h4>\n<p>Here are some of the benefits of reflection.<\/p>\n<ul>\n<li><strong>Testing<\/strong> &#8211; In testing scenarios where the behaviour of a method depends on it&#8217;s private fields, reflection can be used to gain access to those private fields<\/li>\n<li><strong>Debugging<\/strong> &#8211; Can be used by debugging tools<\/li>\n<li><strong>Extensibility<\/strong> &#8211; An application (a plugin or framework for instance) and use user defined classes by using their fully-qualified-names to create extensibility just from object instances.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn about Reflection in Java and how to use it. Overview of Java Reflection How Java Reflection Works Benefits of &hellip; <\/p>\n","protected":false},"author":395,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[28],"tags":[29],"class_list":["post-354","post","type-post","status-publish","format-standard","hentry","category-advanced-java-topics","tag-reflection"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Advanced Java - What is Reflection? - Java Tutorials<\/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:\/\/www.kindsonthegenius.com\/java\/?p=354\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Advanced Java - What is Reflection? - Java Tutorials\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn about Reflection in Java and how to use it. Overview of Java Reflection How Java Reflection Works Benefits of &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/java\/?p=354\" \/>\n<meta property=\"og:site_name\" content=\"Java Tutorials\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-03T17:48:05+00:00\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"headline\":\"Advanced Java &#8211; What is Reflection?\",\"datePublished\":\"2024-03-03T17:48:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354\"},\"wordCount\":434,\"commentCount\":0,\"keywords\":[\"Reflection\"],\"articleSection\":[\"Advanced Java Topics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354\",\"name\":\"Advanced Java - What is Reflection? - Java Tutorials\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\"},\"datePublished\":\"2024-03-03T17:48:05+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?p=354#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Advanced Java &#8211; What is Reflection?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/\",\"name\":\"Java Tutorials\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/#\\\/schema\\\/person\\\/63a68934672db675ff0cd80d066510c2\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/java\\\/author\\\/kindsonthegenius-2\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Advanced Java - What is Reflection? - Java Tutorials","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:\/\/www.kindsonthegenius.com\/java\/?p=354","og_locale":"en_US","og_type":"article","og_title":"Advanced Java - What is Reflection? - Java Tutorials","og_description":"In this tutorial, you will learn about Reflection in Java and how to use it. Overview of Java Reflection How Java Reflection Works Benefits of &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/java\/?p=354","og_site_name":"Java Tutorials","article_published_time":"2024-03-03T17:48:05+00:00","author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/java\/?p=354#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/?p=354"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"headline":"Advanced Java &#8211; What is Reflection?","datePublished":"2024-03-03T17:48:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/?p=354"},"wordCount":434,"commentCount":0,"keywords":["Reflection"],"articleSection":["Advanced Java Topics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/java\/?p=354#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/java\/?p=354","url":"https:\/\/www.kindsonthegenius.com\/java\/?p=354","name":"Advanced Java - What is Reflection? - Java Tutorials","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#website"},"datePublished":"2024-03-03T17:48:05+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/java\/?p=354#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/java\/?p=354"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/java\/?p=354#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/java\/"},{"@type":"ListItem","position":2,"name":"Advanced Java &#8211; What is Reflection?"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/java\/#website","url":"https:\/\/www.kindsonthegenius.com\/java\/","name":"Java Tutorials","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/java\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/java\/#\/schema\/person\/63a68934672db675ff0cd80d066510c2","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3079a7f663b02e801d03cd075852a037af36bd179b5fbcd0603bae3dd7833a9b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/java\/author\/kindsonthegenius-2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/354","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/users\/395"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/comments?post=354"}],"version-history":[{"count":5,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/354\/revisions"}],"predecessor-version":[{"id":382,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/posts\/354\/revisions\/382"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/media?parent=354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/categories?post=354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/java\/wp-json\/wp\/v2\/tags?post=354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}