TreeMap

The TreeMap class implements the Map interface by using a tree. A TreeMap provides an efficient means of storing key/value pairs in sorted order, and allows rapid retrieval. You should note that, unlike a hash map, a tree map guarantees that its elements will be sorted in ascending key order. The TreeMap class supports four ...

Why use Generics in Java?

Generics add a way to specify concrete types to general purpose classes and methods that operated on Object before.   Code that uses generics has many benefits over non-generic code: 1. Stronger type checks at compile time(Compile-time type safety). A Java compiler applies strong type checking to generic code and issues errors if the code violates ...

What is Object-Relational mapping (ORM) framework? 1

Object-relational mapping (ORM, O/RM or O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages. This creates, in effect, a “virtual object database” that can be used from within the programming language. There are both free and commercial packages available that perform ...

UnsupportedClassVersionError

Description : java.lang.UnsupportedClassVersionError:Bad version number in .class file  Cause: When code was compiled on a new version of Java and user is trying to run it on the older version of Java Possible Solution :  Make sure that both the versions are same.  

Understanding Hashcodes

Understanding Hashcodes
Imagine a set of buckets lined up on the floor. Someone hands you a piece of paper with a name on it. You take the name and calculate an integer code from it by using A is 1, B is 2, and so on, and adding the numeric values of all the letters in the ...

Transient variables in Java

Java’s serialization provides an elegant, and easy to use mechanism for making an object’s state persistent. While controlling object serialization, we might have a particular object data member that we do not want the serialization mechanism to save.   The modifier transient can be applied to field members of a class to turn off serialization ...

The ‘Rare’ static imports

The static import declaration imports static members from classes, allowing them to be used without class reference.   for example: import static java.lang.System.*; class A { public static void main(String args[]) { out.println("project code bank"); } }   output: project code bank   Note : Try to avoid this feature, because over a period you may ...

Synchronized Methods and Synchronized Blocks

If you declare a method to be synchronized, then the entire body of the method becomes synchronized; if you use the synchronized block, however, then you can surround just the “critical section” of the method in the synchronized block, while leaving the rest of the method out of the block.   If the entire method ...

Stubs and Skeletons

Stubs and Skeletons
In the distributed computing environment, stub stands for a client side object participating in the distributed object communication and a skeleton stands for a server side object participating in distributed object communication.  Stub  Skeleton  The stub acts as a gateway for client side objects and all outgoing requests to server side objects that are routed through it. The stub wraps ...

Overloading and Overriding

 S.No.    Overloaded Methods  Overridden Methods  1.  Arguments  Must Change  Must not change  2.  Return Type  Can change  Can’t change except for covariant returns  3.  Exceptions  Can change  Can reduce or eliminate. Must not throw new or broader checked exception  4.  Access Modifiers  Can change  Must not make more restrictive (can be less restrictive)  5. ...