In a previous article Everything You Need to Know About Java Serialization, we discussed how serializability of a class is enabled by implementing theSerializable interface. If our class does not implement Serializable interface or if it is having a reference to a non Serializable class then JVM will throw NotSerializableException. All subtypes of a serializable class are themselves serializable andExternalizable ...
Read More »Home »
How To Deep Clone An Object Using Java In Memory Serialization
In my previous articles, I had explained the difference between deep and shallow cloning and how copy-constructors and defensive copy methods are better than default java cloning. Java object cloning using copy constructors and defensive copy methods certainly have some advantages but we have to explicitly write some code to achieve deep cloning in all these approaches. And still, there ...
Read More »How to Customize Serialization In Java By Using Externalizable Interface
In a previous article Everything About Java Serialization Explained With Example, I explained how we can serialize/deserialize one object usingSerializable interface and also explain how we can customise the serialization process using writeObject and readObject methods. Disadvantages Of Java Serialization Process But these customizations are not sufficient because JVM has full control of the serialization process and those customization logics ...
Read More »What is Serialization? Everything You Need to Know About Java Serialization Explained With Example
In a previous article, we looked at 5 different ways to create objects in java, I have explained how deserialising a serialised object creates a new object and in this blog, I am going to discuss Serialization and Deserialization in details. We will use below Employee class object as an example for the explanation 01 02 03 04 05 06 ...
Read More »How to Install Multiple Versions of Java on the Same Machine
Some time back I have written one articleJava Lambda Expression Explained with Example but it was easy for me to explore and Java 8 because I was using it in my project and I was allowed to install and use it. But in my current project, we are still using Java 8 and now I want to upgrade myself and ...
Read More »Useful Git Commands
Git is a most widely used and powerful version control system for tracking changes in computer files and coordinating work on those files among multiple people. It is primarily used for source code management in software development, but it can be used to keep track of changes in any set of files. Git was developed by Linus Torvalds in 2005 ...
Read More »Java Integer Cache – Why Integer.valueOf(127) == Integer.valueOf(127) Is True
In an interview, one of my friends was asked that if we have two Integer objects, Integer a = 127; Integer b = 127; Why a == b evaluate to true when both are holding two separate objects? In this article, I will try to answer this question and also try to explain the answer. Short Answer The short answer to this question is, ...
Read More »Why Instance Variable Of Super Class Is Not Overridden In Sub Class
When we create a variable in both parent and child class with the same name, and try to access it using parent’s class reference which is holding a child class’s object then what do we get? In order to understand this, let us consider below example where we declare a variable x with the same name in bothParent andChild classes. class ...
Read More »