Wrapper Classes in Java

In this tutorial, I am going to explain what are wrapper classes in java. Why it is introduced and the concept of autoboxing and unboxing.

Wrapper Class

As the name suggests, a wrapper class wraps (encloses) around a primitive data type and gives it an object appearance. In simple words, we can convert primitive data types into an object using their corresponding wrapper class.

Wrapper classes are final and immutable.

How to create immutable class in java

For example:

Primitive Data Type

A primitive data type defines the size and type of variable values. In Java, we have eight primitive data types, which are as follows:

Serialize and Deserialize Binary Tree

Given a binary tree, write a code to serialize and deserialize binary tree.

You can choose any algorithm for serialization and deserialization of a binary tree. But make sure the algorithm we choose to serialize a binary tree to a string and can also deserialize the string representation to the original tree structure.

What is serialization and deserialization?

Before solving this problem, let’s first understand what is serialization and deserialization?

In Serialization, the data structure or object is translated/converted into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network.

Deserialization is the process to reconstruct the data structure or object from the sequence of bits.