How do we use a Java decompiler

Normally when you use a third party library without attaching the source-code you won’t see much interesting. Depending on your IDE you’ll either see the method declarations and the occasional constant along with a note to download the source code or if you’re using eclipse you may see a “Source not find” error along with
something […]

Sorting an array of Strings in Java

Sorting an array in java can be done with the help of static methods provided by ‘Arrays’ class. This class specifically works with arrays and it can perform various search operations on array elements as well.

Following code depicts how to use a simple static method provided by this class to sort a String array:

The output […]

Importance of flush method in I/O

I/O operations in Java are performed with the help of I/O streams. I/O stream is basically a representation of an input source or output destination in any I/O operation. These sources and destination can be disk files, devices, memory block represented by data structures. I/O streams can operate at byte level, character level or object […]

For each loop in Java

For each looping construct is an enhanced convenience feature added after Java 5.0. This looping construct can be used to iterate over the elements which implement Iterable interface.

Syntax for enhanced for loop is

While working on collections, most of the times we have to iterate over them to perform any operations. Let us consider […]

Difference between signed and unsigned right shift operators

In memory, all the information is stored in its binary representation i.e. series of 0s and 1s. To ease the operations on binary numbers, Java like other programming languages provides bit level operators. ‘>>’ and ‘>>>’ are bit level shift operators which are basically used to shift the number of bits of the left […]

Difference between a Connection and a DataSource

Any enterprise application needs to communicate to the data store to store some data and retrieve it later when needed. This data source can be a database, file system or some external hardware. When an application uses JDBC to connect to the database there are two ways by which it can do that:

Using DriverManager class

This […]

Creating a copy of an object in Java

There are basically 3 ways by which we can create an exact copy of an object in Java.

Cloning of an object

Java language specification provides a mechanism to create an exact copy of an object with the help of ‘clone()’ method of java.lang.Object class. The specification provides default implementation of this method. The default implementation does […]

Converting String to an equivalent int primitive

java.util.Integer class is a wrapper class provided for int type primitives. It contains only one field of type ‘int’ and many helper methods to convert the int to String and vice versa. It also contains many useful methods and constants required to operate on int primitives in any mathematical problem.

This class provides a method […]

Setting the classpath using Eclipse differ from setting it using environment variables

A classpath is a parameter which controls where the Java interpreter or compiler will look for user defined classes. By user defined classes we mean any class that doesn’t come with the standard Java distribution either written by the programmer himself or taken from some library.

Let’s work with an example:

For the example to work we […]

Fail fast and fail safe iterators in Java

Java distinguishes between two types of iterators – the *fail fast* iterator and *fail safe* iterator. Unfortunately to know what type of iterator your collection returns you need to read into the javadoc and read the description of the `iterator()` method. Though, a good rule of a thumb is that most iterators are fail fast, […]

Java ExperienceA place for all type of Java web tutorials2015