Java Tiger | DeepakGaikwad.net
Home » Archive

Articles tagged with: Java Tiger

Java, Tech Notes »

[20 Jul 2009 | No Comment | ]

Annotation is not a new feature getting introduced in Java 5, but in this release Java is trying to explore the power of this feature. If we look at the open source product stack adapting to Java 5, then this is the feature what has changed most of the products considerably. It has begun a new era of decorative programming. In this article, it is assumed that you already have knowledge of Java, and can appreciate this article focusing on the concept of annotations, use of annotations etc.
Annotations Prior to …

Java, Tech Notes »

[10 Jul 2009 | No Comment | ]

Static keyword is used to allow access to an attribute/ a method or a class without creating instance of it. (Some of you may argue that this is not object oriented way, but we leave that discussion aside for now.) We use static for those elements which do not change from instance to instance of a class. An example would be constant variables in a program. These values are stored using ‘public static final’ keywords. In enum article we have seen one way of managing logically linked constants. Static import …

Java, Tech Notes »

[9 Jul 2009 | One Comment | ]

Varargs means variable arguments, something really different from normal Java language syntax. Normally, we define method signature to offer a contract to the callers of that method by restricting number and type of input parameters, return data type and exceptions thrown. Using vararg feature, we can overcome this restriction partially and make the signature dynamic. You may say that the dynamic signature is not new. Following two options you used many times to avoid an impact on clients due to additional/reduced parameters in signatures.

Using array/collection as an input parameter

Java, Tech Notes »

[8 Jul 2009 | 18 Comments | ]

Enumerations already existed in other languages like C, C++, SmallTalk etc. Enums are used primarily to handle a collection of logically grouped constants. In Java, for ages we have been handling constants (number constants here) through separate Java files, sometimes by encapsulating those in relevant POJOs, and even using a wrong design style of implementing an interface containing all constants. We used these constants in conditions implemented using ‘if’ statement or switch cases also. First thing you can notice about all these approaches is that this made the code look …

Java, Tech Notes »

[6 Jul 2009 | No Comment | ]

Autoboxing feature in Java 5 is to make code look neater and cleaner. Autoboxing, as name suggests, does something automatically. It converts data types from one form to other automatically. This does not apply to any data type but to some selected data types which allow this conversion (generally without losing out any information). Using autoboxing, primitive data type values can be converted into respective wrapper objects and vice versa. Take a look at some of the data types that can avail this feature of autoboxing.

int <– –> Integer
boolean <– …