How to learn java online with examples

Java the most popular programming language since the inception of  C++ is greatly appreciated for its Code once and Run anywhere capability , Object Orientation and above all its automatic memory management. Java is found every where from embedded devices, mobile phones, tablets, desktop computers… Read More

Java Comparator and Comparable demystified

Java comparator and java comparable both achieve the same thing, helps to sort objects and both are Interfaces. Let us first explore comparable ( java.lang.comparable) and then comparator ( java.util.Comparator ). Comparable Quick facts: Belongs to java.lang  package and has a single method int compareTo(T o).  The… Read More

How to rename a file in java

You can easily rename a file in Java using the renameTo()  method. But there is a catch. This methods works in a platform specific manner. The file may get renamed if tried on a linux machine and may fail on windows. Hence it is very important… Read More

How to read a file in Java

In Java, you can adopt many ways to read contents of a file. In this tutorial let us explore the most common way of reading a file using java. The steps for reading a file can be broadly broken down into 3 simple steps Open a… Read More

Uses of Finalize method in Java

In Java, finalize is a method that garbage collector must run on the object before freeing or garbage collecting the object. To add a finalizer to a class, just declare it as follows:

The finalize method is defined in the java.lang.Object class and you… Read More

How to get the current timestamp In Java

Getting the current timestamp in java  is straightforward. Here is how you can get this

Another problem usually people ask is how to find the elapsed time between two timestamps or date. This is also very easy to find in java. The steps are… Read More