Lec 3-8
Lec 3-8
clone() method is present in the Object class. It creates and returns a copy of the
object.
Ways to Create an Object of a Class
4. Deserialization
● It is a type of inner class that is the same as local classes but the only
difference is that the class has not a class name and a single object is
created of the class. It makes the code more concise. There are two
ways.
○ By using an interface
○ By declaring the class concrete and abstract
Anonymous inner class example
Now that you know inner class, you may have…
Wrapper Class
● In Java, the term wrapper class represents a collection of Java classes
that objectify the primitive type of Java.
● It means that for each primitive type there is a corresponding wrapper
class. The wrapper classes are used to perform the conversion from a
primitive type to an object and vice-versa.
● To understand wrapper class hierarchy we first revisit the data type
hierarchy.
Java Data Type Tree
Java Wrapper Class Hierarchy and Options
Wrapper Classes Example (for JDK <=8)
Wrapper Classes Example (result and alternative)
Autoboxing and Unboxing