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 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 …
Java Exception Handling
Let’s look at Java exception handling. It is one of the most useful topics and can be confusing at times. But Java exceptions are pretty simple to understand and here we will try to cover most of Java exception handling. Some Questions: Why do we need exception handling in Java? Differences between checked and unchecked …
Java Strings, StringBuilder, StringBuffer
Lets learn more about Strings in Java today. Java Strings are one of the most commonly used and hence we will explore about it in detail. Some of the key differences in Java Strings over other languages are: String is an object in Java and is part of the java.lang package. To invoke objects of …