Archive | February 19th, 2009

Volatile keyword in Java

February 19, 2009

10 Comments

This tips explains the use of volatile keyword in Java. The keyword volatile is used in the multithreaded environment. Local Variables in the Thread If you are working with the multithreaded programming, the volatile keyword will be more useful. When multiple threads using the same variable, each thread will have its own copy of the [...]

email

Working with arrays : java.util.Arrays class

February 19, 2009

0 Comments

The java.util.Arrays class is basically a set of static methods that are all useful for working with arrays. The Arrays class contains various methods for manipulating arrays (such as sorting and searching). In addition to that, it has got many utility methods for using with arrays such as a method for viewing arrays as lists [...]

How to use Enum in Switch?

February 19, 2009

18 Comments

Enums introduced in Java 5.0 (Read: New features in Java 5.0) allows switching to be done based on the enums values. It is one of the greatest new features introduced from the version 5.0. Prior to Java 1.4, switch only worked with int, short, char, and byte values. However, since enums have a finite set of [...]

Adding methods to an Enum

February 19, 2009

0 Comments

Enums introduced in Java 5.0 are just compiled java classes with some extra behaviour. So you can basically do whatever you can in a normal java class inside an enum as well. That includes adding methods , class level variables and constructors to an enum. Adding methods to an enum works just like adding methods [...]