Category Archives: Java Tutorial

How to Compare Dates in Java

In this tutorial you will learn how to compare dates in Java. There are mainly three different ways to compare two dates in Java. 1. Using compareTo() method 2. Using equals(), before() and after() method 3. Using getTime() method Below I have shared one example for each of these methods. How to Compare Dates in… Read More »

Generate Random Number in Java in a Range

In this tutorial I will teach you how to generate random number in Java in a range. There are two ways by which Java random number can be generated. The first way is to use nextInt() method of java.util.Random class and second way is to use random() method of java.lang.Math class. Below I have shared… Read More »

Java JSON Example

In this tutorial you will learn about Java JSON example. What is JSON? JSON stands for JavaScript Object Notation. JSON is a lightweight and an easier way for exchanging data on the web. JSON is originated from JavaScript programming language. JSON is a good alternative of XML. JSON is language independent and supports data structures… Read More »

Serialization in Java with Example

Serialization in Java is the process of converting an object into bytes stream to save it in file. Or we can say that, serialization is used to persist (save) the state of an object. The process of recreating object from bytes stream is called deserialization. Below I have mentioned few applications of serialization in Java.… Read More »

Java Program for Tower of Hanoi Problem

Source of Tower of Hanoi has been after Tower of Brahma custom. Story begins like this, in an antiquated sanctuary of Kashi which contains a huge room with three towers in it encompassed by 64 golden disks. At the time of formation of the world, Brahma made a precious stone tower with 64 discs made… Read More »

How to Execute Your Java Program Without main() Method?

Have you ever thought about executing your java program without main() method? If you write a program without main() and compile it then it will compile successfully. But as you execute the program it will show an error that Main method not found in the class. JVM verify the code before its execution. JVM checks… Read More »