We all know, all Java classes are subclasses of a special class called Object. Let’s look at one special method inside the Object class. You may think, the return type Class is the actual class that we write with the…
Cloning
Introduction We know that objects as well as primitive data types can be passed to methods as a parameter. But there is a major difference between passing a primitive data type and object. When we pass a primitive, we just…
Serialization
Introduction Serialization is a mechanism to convert the state of an object into a byte stream. This byte stream can be saved to a database or a file or we can transfer over a network. Deserialization is the exact opposite…
Garbage Collection
The problem In Java, when we create an object, it is stored in the Heap memory. All the objects in Heap are accessed through references. We can consider reference as a pointer to an object in Heap. If a program…
Thread – Part 3
Executing Tasks in Threads We can consider a task as an independent activity that doesn’t depend on the result or side effect of other tasks. So, if you have sufficient resources (CPU, memory etc.), tasks can be executed in parallel.…
Thread – Part 2
Synchronizers A synchronizer is any object that determines whether threads arriving at it should be forced to wait or allowed to proceed based on its state. Examples of synchronizers are semaphores, barriers, and latches. CountDownLatch A latch acts just like…
Thread – Part 1
Introduction A thread in Java simply means a single independent path to execute a group of statements one after another. Every thread in Java is represented by an object of class Thread. When we write a code, we basically write…
JDBC
Introduction As you know, a database is used to store information in an organized way so that we can easily store and access that information. If you want to interact with SQL databases, you have to use the JDBC (Java…
Exception Handling
Introduction In java, when you write some code and the syntax is incorrect, the compiler will not allow you to compile the code unless you fix the syntax error. But even if the syntax is correct, some real bad things…
comparable and comparator
Comparing the two numeric values like two integers or two float values are easy in Java. You just have to use arithmetic operators. Here we have used the greater than (>) operator to compare two numeric values. Now, let’s try…