{"id":205,"date":"2025-06-24T06:52:52","date_gmt":"2025-06-24T06:52:52","guid":{"rendered":"https:\/\/thetestdata.com\/blog\/?p=205"},"modified":"2025-07-16T10:29:01","modified_gmt":"2025-07-16T10:29:01","slug":"what-is-autoboxing-and-unboxing","status":"publish","type":"post","link":"https:\/\/thetestdata.com\/blog\/what-is-autoboxing-and-unboxing\/","title":{"rendered":"What is Autoboxing and Unboxing?"},"content":{"rendered":"\n<p><strong>autoboxing<\/strong> and <strong>unboxing<\/strong> are features that automatically convert between <em>primitive types<\/em> (like <code>int<\/code>, <code>char<\/code>, <code>double<\/code>) and their corresponding <em>wrapper classes<\/em> (<code>Integer<\/code>, <code>Character<\/code>, <code>Double<\/code>, etc.).<\/p>\n\n\n\n<p>\ud83e\udde0 <strong>Autoboxing<\/strong><\/p>\n\n\n\n<p>This is when Java <em>automatically converts a primitive type into its wrapper class<\/em>.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"912\" height=\"214\" src=\"https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-1.png\" alt=\"\" class=\"wp-image-207\" srcset=\"https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-1.png 912w, https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-1-300x70.png 300w, https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-1-768x180.png 768w\" sizes=\"auto, (max-width: 912px) 100vw, 912px\" \/><\/figure>\n\n\n\n<p>\ud83d\udd04 <strong>Unboxing<\/strong><\/p>\n\n\n\n<p>This is when Java <em>automatically converts an object of a wrapper class back into a primitive type<\/em>.<\/p>\n\n\n\n<p><strong>Example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"892\" height=\"199\" src=\"https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-2.png\" alt=\"\" class=\"wp-image-208\" srcset=\"https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-2.png 892w, https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-2-300x67.png 300w, https:\/\/thetestdata.com\/blog\/wp-content\/uploads\/2025\/06\/image-2-768x171.png 768w\" sizes=\"auto, (max-width: 892px) 100vw, 892px\" \/><\/figure>\n\n\n\n<p>These features make your code cleaner and more intuitive, especially when working with collections like <code>ArrayList<\/code>, which can&#8217;t store primitives directly.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Understand autoboxing and unboxing in Java. Learn how primitive types and wrapper classes are automatically converted for cleaner, more flexible code<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[17],"tags":[],"class_list":["post-205","post","type-post","status-publish","format-standard","hentry","category-java-interview-questions"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/posts\/205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/comments?post=205"}],"version-history":[{"count":2,"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":457,"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/posts\/205\/revisions\/457"}],"wp:attachment":[{"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/media?parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/categories?post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thetestdata.com\/blog\/wp-json\/wp\/v2\/tags?post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}