{"id":5147,"date":"2024-12-17T22:56:01","date_gmt":"2024-12-17T17:56:01","guid":{"rendered":"https:\/\/afzalbadshah.com\/?p=5147"},"modified":"2024-12-18T08:30:25","modified_gmt":"2024-12-18T03:30:25","slug":"understanding-serialization-in-java-a-beginners-guide","status":"publish","type":"post","link":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/","title":{"rendered":"Understanding Serialization in Java: A Beginner&#8217;s Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we&#8217;ll discuss how serialization and deserialization work in Java using a simple <code>Car<\/code> class. The process of serialization allows you to save the state of an object to a file, while deserialization allows you to read that object back into memory.  Here, we will explore the steps of serializing and deserializing an <code>Car<\/code> object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We begin with a <code>Car<\/code> class, which implements the <code>Serializable<\/code> interface. This is essential because Java needs to know that the objects of this class can be converted to a byte stream and saved to a file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import java.io.*;\n\n\/\/ Simple Car class implementing Serializable\nclass Car implements Serializable {\n    String make;\n    int year;\n\n    Car(String make, int year) {\n        this.make = make;\n        this.year = year;\n    }\n}\n\npublic class CarSerializableExample {\n    public static void main(String&#91;] args) throws Exception {\n        \/\/ Writing the object (Serialization)\n        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(\"car.txt\"));\n        Car car1 = new Car(\"Toyota\", 2021);\n        out.writeObject(car1);\n        out.close();\n        \n        \/\/ Reading the object (Deserialization)\n        ObjectInputStream in = new ObjectInputStream(new FileInputStream(\"car.txt\"));\n        Car readCar = (Car) in.readObject();\n        in.close();\n\n        System.out.println(\"Car Make: \" + readCar.make);\n        System.out.println(\"Car Year: \" + readCar.year);\n    }\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, the <code>Car<\/code> class implements <code>Serializable<\/code>, indicating that its objects can be serialized. The <code>Car<\/code> class has two attributes: <code>make<\/code> (the car&#8217;s make) and <code>year<\/code> (the car&#8217;s manufacturing year). We provide a constructor to initialize these values.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"254\" src=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/image-1.png?resize=640%2C254&#038;ssl=1\" alt=\"\" class=\"wp-image-5150\" srcset=\"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/image-1.png?w=800&amp;ssl=1 800w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/image-1.png?resize=300%2C119&amp;ssl=1 300w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/image-1.png?resize=768%2C305&amp;ssl=1 768w, https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/image-1.png?resize=604%2C240&amp;ssl=1 604w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><figcaption class=\"wp-element-caption\">Serialization process<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Serialization Process<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Serialization is the process of converting an object into a stream of bytes so that it can be saved to a file or transferred. In this example, we use the <code>ObjectOutputStream<\/code> to serialize the object and write it to a file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(\"car.txt\"));\nCar car1 = new Car(\"Toyota\", 2021);\nout.writeObject(car1);\nout.close();\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ObjectOutputStream<\/strong> is used to write the object to a file. We create an instance of <code>ObjectOutputStream<\/code> and pass a <code>FileOutputStream<\/code> that points to the file <code>car.txt<\/code>.<\/li>\n\n\n\n<li>We create a <code>Car<\/code> object (<code>car1<\/code>) and initialize it with <code>\"Toyota\"<\/code> as the make and <code>2021<\/code> as the year.<\/li>\n\n\n\n<li>The <code>writeObject(car1)<\/code> method is called to serialize the <code>car1<\/code> object and save it to the file.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Deserialization Process<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Deserialization is the opposite of serialization. It reads the byte stream from the file and converts it back into an object. In our example, we use <code>ObjectInputStream<\/code> to deserialize the object.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ObjectInputStream in = new ObjectInputStream(new FileInputStream(\"car.txt\"));\nCar readCar = (Car) in.readObject();\nin.close();\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ObjectInputStream<\/strong> is used to read the object from the file. We create an instance of <code>ObjectInputStream<\/code> and pass a <code>FileInputStream<\/code> that points to the file <code>car.txt<\/code>.<\/li>\n\n\n\n<li>We use the <code>readObject()<\/code> method to read the object and cast it back to the <code>Car<\/code> class.<\/li>\n\n\n\n<li>Finally, we close the <code>ObjectInputStream<\/code>.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Output<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After deserialization, we can access the attributes of the <code>Car<\/code> object and print them to the console:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>System.out.println(\"Car Make: \" + readCar.make);\nSystem.out.println(\"Car Year: \" + readCar.year);\n<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We access the <code>make<\/code> and <code>year<\/code> attributes of the <code>readCar<\/code> object and print them. This will display the make and year of the car that was read from the file.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we&#8217;ll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a file, while deserialization allows you to read that object back into memory. Here, we will explore the steps of serializing and deserializing an Car object&#8230;.<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":5148,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[602],"tags":[612,603,647],"class_list":["post-5147","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-object-oriented-programing-oop","tag-java","tag-oop","tag-serialization"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we&#039;ll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Afzal Badshah, PhD\"\/>\n\t<meta name=\"google-site-verification\" content=\"B8FNGv4w1toMpU3HUnD_SN9H9YMtp1ObsLuEDuirArI\" \/>\n\t<meta name=\"p:domain_verify\" content=\"87b5ca26c36438b20581a102dc290a47\" \/>\n\t<meta name=\"yandex-verification\" content=\"0eb3e2a9157fd34d\" \/>\n\t<meta name=\"keywords\" content=\"java,oop,serialization,object oriented programing (oop)\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_GB\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Afzal Badshah, PhD - Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Understanding Serialization in Java: A Beginner\u2019s Guide - Afzal Badshah, PhD\" \/>\n\t\t<meta property=\"og:description\" content=\"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we&#039;ll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp\" \/>\n\t\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-12-17T17:56:01+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-12-18T03:30:25+00:00\" \/>\n\t\t<meta property=\"article:publisher\" content=\"https:\/\/web.facebook.com\/abmanduri\/\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@DrAFZALBADSHAH\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Understanding Serialization in Java: A Beginner\u2019s Guide - Afzal Badshah, PhD\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we&#039;ll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@DrAFZALBADSHAH\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp\" \/>\n\t\t<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t\t<meta name=\"twitter:data1\" content=\"Afzal Badshah, PhD\" \/>\n\t\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#blogposting\",\"name\":\"Understanding Serialization in Java: A Beginner\\u2019s Guide - Afzal Badshah, PhD\",\"headline\":\"Understanding Serialization in Java: A Beginner&#8217;s Guide\",\"author\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/afzalbadshah.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/Abstract-Classes-in-Java-1.webp?fit=1920%2C1080&ssl=1\",\"width\":1920,\"height\":1080},\"datePublished\":\"2024-12-17T22:56:01+05:00\",\"dateModified\":\"2024-12-18T08:30:25+05:00\",\"inLanguage\":\"en-GB\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#webpage\"},\"articleSection\":\"Object Oriented Programing (OOP), java, OOP, serialization\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/afzalbadshah.com\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/#listItem\",\"name\":\"Courses\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/#listItem\",\"position\":2,\"name\":\"Courses\",\"item\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/object-oriented-programing-oop\\\/#listItem\",\"name\":\"Object Oriented Programing (OOP)\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/object-oriented-programing-oop\\\/#listItem\",\"position\":3,\"name\":\"Object Oriented Programing (OOP)\",\"item\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/object-oriented-programing-oop\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#listItem\",\"name\":\"Understanding Serialization in Java: A Beginner&#8217;s Guide\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/#listItem\",\"name\":\"Courses\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#listItem\",\"position\":4,\"name\":\"Understanding Serialization in Java: A Beginner&#8217;s Guide\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/category\\\/courses\\\/object-oriented-programing-oop\\\/#listItem\",\"name\":\"Object Oriented Programing (OOP)\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#person\",\"name\":\"Afzal Badshah, PhD\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#personImage\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/wp-content\\\/litespeed\\\/avatar\\\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1786545756\",\"width\":96,\"height\":96,\"caption\":\"Afzal Badshah, PhD\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/\",\"name\":\"Afzal Badshah, PhD\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#authorImage\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/wp-content\\\/litespeed\\\/avatar\\\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1786545756\",\"width\":96,\"height\":96,\"caption\":\"Afzal Badshah, PhD\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#webpage\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/\",\"name\":\"Understanding Serialization in Java: A Beginner\\u2019s Guide - Afzal Badshah, PhD\",\"description\":\"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we'll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a\",\"inLanguage\":\"en-GB\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/author\\\/afzalbadshah-com\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/afzalbadshah.com\\\/wp-content\\\/uploads\\\/2024\\\/12\\\/Abstract-Classes-in-Java-1.webp?fit=1920%2C1080&ssl=1\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#mainImage\",\"width\":1920,\"height\":1080},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/index.php\\\/2024\\\/12\\\/17\\\/understanding-serialization-in-java-a-beginners-guide\\\/#mainImage\"},\"datePublished\":\"2024-12-17T22:56:01+05:00\",\"dateModified\":\"2024-12-18T08:30:25+05:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#website\",\"url\":\"https:\\\/\\\/afzalbadshah.com\\\/\",\"name\":\"Afzal Badshah, PhD\",\"alternateName\":\"Afzal Badshah\",\"description\":\"Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence\",\"inLanguage\":\"en-GB\",\"publisher\":{\"@id\":\"https:\\\/\\\/afzalbadshah.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Understanding Serialization in Java: A Beginner\u2019s Guide - Afzal Badshah, PhD","description":"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we'll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a","canonical_url":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/","robots":"max-image-preview:large","keywords":"java,oop,serialization,object oriented programing (oop)","webmasterTools":{"google-site-verification":"B8FNGv4w1toMpU3HUnD_SN9H9YMtp1ObsLuEDuirArI","p:domain_verify":"87b5ca26c36438b20581a102dc290a47","yandex-verification":"0eb3e2a9157fd34d","miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#blogposting","name":"Understanding Serialization in Java: A Beginner\u2019s Guide - Afzal Badshah, PhD","headline":"Understanding Serialization in Java: A Beginner&#8217;s Guide","author":{"@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author"},"publisher":{"@id":"https:\/\/afzalbadshah.com\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp?fit=1920%2C1080&ssl=1","width":1920,"height":1080},"datePublished":"2024-12-17T22:56:01+05:00","dateModified":"2024-12-18T08:30:25+05:00","inLanguage":"en-GB","mainEntityOfPage":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#webpage"},"isPartOf":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#webpage"},"articleSection":"Object Oriented Programing (OOP), java, OOP, serialization"},{"@type":"BreadcrumbList","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com#listItem","position":1,"name":"Home","item":"https:\/\/afzalbadshah.com","nextItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/#listItem","name":"Courses"}},{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/#listItem","position":2,"name":"Courses","item":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/","nextItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/object-oriented-programing-oop\/#listItem","name":"Object Oriented Programing (OOP)"},"previousItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/object-oriented-programing-oop\/#listItem","position":3,"name":"Object Oriented Programing (OOP)","item":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/object-oriented-programing-oop\/","nextItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#listItem","name":"Understanding Serialization in Java: A Beginner&#8217;s Guide"},"previousItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/#listItem","name":"Courses"}},{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#listItem","position":4,"name":"Understanding Serialization in Java: A Beginner&#8217;s Guide","previousItem":{"@type":"ListItem","@id":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/object-oriented-programing-oop\/#listItem","name":"Object Oriented Programing (OOP)"}}]},{"@type":"Person","@id":"https:\/\/afzalbadshah.com\/#person","name":"Afzal Badshah, PhD","image":{"@type":"ImageObject","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#personImage","url":"https:\/\/afzalbadshah.com\/wp-content\/litespeed\/avatar\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1786545756","width":96,"height":96,"caption":"Afzal Badshah, PhD"}},{"@type":"Person","@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author","url":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/","name":"Afzal Badshah, PhD","image":{"@type":"ImageObject","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#authorImage","url":"https:\/\/afzalbadshah.com\/wp-content\/litespeed\/avatar\/27d3d5e33aa81b3152e368c66871f22f.jpg?ver=1786545756","width":96,"height":96,"caption":"Afzal Badshah, PhD"}},{"@type":"WebPage","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#webpage","url":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/","name":"Understanding Serialization in Java: A Beginner\u2019s Guide - Afzal Badshah, PhD","description":"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we'll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a","inLanguage":"en-GB","isPartOf":{"@id":"https:\/\/afzalbadshah.com\/#website"},"breadcrumb":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#breadcrumblist"},"author":{"@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author"},"creator":{"@id":"https:\/\/afzalbadshah.com\/index.php\/author\/afzalbadshah-com\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp?fit=1920%2C1080&ssl=1","@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#mainImage","width":1920,"height":1080},"primaryImageOfPage":{"@id":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/#mainImage"},"datePublished":"2024-12-17T22:56:01+05:00","dateModified":"2024-12-18T08:30:25+05:00"},{"@type":"WebSite","@id":"https:\/\/afzalbadshah.com\/#website","url":"https:\/\/afzalbadshah.com\/","name":"Afzal Badshah, PhD","alternateName":"Afzal Badshah","description":"Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence","inLanguage":"en-GB","publisher":{"@id":"https:\/\/afzalbadshah.com\/#person"}}]},"og:locale":"en_GB","og:site_name":"Afzal Badshah, PhD - Unlocking Mastery in Parenting, Teaching, Learning, Academic, and Life Skills: Your Guide to Excellence","og:type":"article","og:title":"Understanding Serialization in Java: A Beginner\u2019s Guide - Afzal Badshah, PhD","og:description":"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we'll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a","og:url":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/","og:image":"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp","og:image:secure_url":"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp","og:image:width":1920,"og:image:height":1080,"article:published_time":"2024-12-17T17:56:01+00:00","article:modified_time":"2024-12-18T03:30:25+00:00","article:publisher":"https:\/\/web.facebook.com\/abmanduri\/","twitter:card":"summary_large_image","twitter:site":"@DrAFZALBADSHAH","twitter:title":"Understanding Serialization in Java: A Beginner\u2019s Guide - Afzal Badshah, PhD","twitter:description":"Serialization is an important concept in Java, especially when you need to save the state of objects or transfer them over a network. In this tutorial, we'll discuss how serialization and deserialization work in Java using a simple Car class. The process of serialization allows you to save the state of an object to a","twitter:creator":"@DrAFZALBADSHAH","twitter:image":"https:\/\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp","twitter:label1":"Written by","twitter:data1":"Afzal Badshah, PhD","twitter:label2":"Est. reading time","twitter:data2":"3 minutes"},"aioseo_meta_data":{"post_id":"5147","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"Serialization","score":78,"analysis":{"keyphraseInTitle":{"score":9,"maxScore":9,"error":0},"keyphraseInDescription":{"score":9,"maxScore":9,"error":0},"keyphraseLength":{"score":9,"maxScore":9,"error":0,"length":1},"keyphraseInURL":{"score":5,"maxScore":5,"error":0},"keyphraseInIntroduction":{"score":9,"maxScore":9,"error":0},"keyphraseInSubHeadings":{"score":9,"maxScore":9,"error":0},"keyphraseInImageAlt":{"score":3,"maxScore":9,"error":1},"keywordDensity":{"type":"high","score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2024-12-17 17:53:14","updated":"2025-06-10 22:20:35","focus_keyword":"Serialization","additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/afzalbadshah.com\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/\" title=\"Courses\">Courses<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/object-oriented-programing-oop\/\" title=\"Object Oriented Programing (OOP)\">Object Oriented Programing (OOP)<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tUnderstanding Serialization in Java: A Beginner\u2019s Guide\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/afzalbadshah.com"},{"label":"Courses","link":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/"},{"label":"Object Oriented Programing (OOP)","link":"https:\/\/afzalbadshah.com\/index.php\/category\/courses\/object-oriented-programing-oop\/"},{"label":"Understanding Serialization in Java: A Beginner&#8217;s Guide","link":"https:\/\/afzalbadshah.com\/index.php\/2024\/12\/17\/understanding-serialization-in-java-a-beginners-guide\/"}],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/afzalbadshah.com\/wp-content\/uploads\/2024\/12\/Abstract-Classes-in-Java-1.webp?fit=1920%2C1080&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pf3emP-1l1","jetpack-related-posts":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/5147","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/comments?post=5147"}],"version-history":[{"count":2,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/5147\/revisions"}],"predecessor-version":[{"id":5151,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/posts\/5147\/revisions\/5151"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/media\/5148"}],"wp:attachment":[{"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/media?parent=5147"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/categories?post=5147"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afzalbadshah.com\/index.php\/wp-json\/wp\/v2\/tags?post=5147"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}