Serialization is a process by which data structures or objects are translated into a format or a sequence of bytes (often called marshaling), which can later be unpacked (often called unmarshalling) in the same/different environment. Since the two environments might be completely different, a common method of serialization and then later deserialization is required. Questions: …
Java Iterable and Iterator Interface
One of the most widely used and most common API in Java is iterator for the collections. If we have the list of objects in an array or list objects, the iterator is very useful for iterating the objects without much extra coding. Here we discuss about the comparison of two key interfaces, Iterable and …
Java Access Modifiers
Questions to be answered: What are access modifiers and why do we need them in Java? What are the class-level and method-level access modifiers and its visibility? Access modifiers assists in maintaining the Encapsulation property of Object Oriented Programming concept. For now, just assume that Public means accessible by anyone who has a copy of …
Java Varargs
In this article, we will discuss about passing variable number of arguments to Java methods. Variable arguments feature was introduced in Java 1.5 and it is a very useful feature as we will see in the below examples. Also Read: Java 5 New Features Java 7 Tutorials Java 8 Tutorials Prior to Java 1.5 Lets …
Java equals() and hashcode()
This tutorial explains the equals() and hashcode() method in simple terms. It is one of the confusing questions on the Java developer’s mind. The common questions asked about these methods are: What is equals() method and why should I override that in our classes? What is hashcode() method? Why should I always override hashcode() when …
Java 7 New Features
As with every new Java version, Java 7 introduced some new features. The new features are definitely worth the change and as developers, we must be happy as we can be more efficient. There are many features introduced in Java 7 but we will look at some of them. Allows Strings to be used in …
Java Immutable Objects
Objects whose state can’t be changed after its creation are called immutable objects. It is considered an effective strategy to make objects immutable if they are going to be used in multithreaded applications. Java’s built-in Strings, Integers are all immutable objects and so there must be some solid reasoning behind that. In this article, lets …
Comparable vs Comparator Interface in Java
This is an interesting topic in Java and can be confusing to many Java developers. So I plan to give some common examples to illustrate the differences. Going by the topic name, these things are obvious to us: Both comparator and comparable are Java interfaces. Any class, which needs to use these interfaces, has to …