Jar, War, and Ear files

.ear, .war, and .jar files are simply files zipped using Java jar tool. Each file is created for a different purpose:

.jar files

Jar (Java Archive) files contain libraries, resources and accessory files such as property files.

.war files

War (Web Archive) files contain web applications that can be deployed on any servlet/jsp container. It also contains other files required by the web application such as html, javascript, css, etc.

.ear files

Ear (Enterprise Archive) files contain EJB modules.

Java and Memory

From a programming point of view, there are essentially six different places to store data on your computer. The fastest storage is the registers since this memory resides inside the processor itself. No high-level language gives you direct access to this memory.

Java break and continue

Java’s break and continue statements are used to alter the flow of control.

break The break statement can be used in for, while or do-while loops. It is also used in switch structure. A break statement exits the loop without executing the rest of the code in the loop. In other words, if the program encounters a break inside a for loop, it exits the loop without executing the remaining statements even if the test condition of the loop is still valid.

ArrayList NullPointerException

Java's ArrayList is a great Collection that frees us from IndexOutOfBound, one type limitation, and NullPointerException issues while providing several value-added methods. Naturally, you would be shocked if you encounter a NullPointerException on an ArrayList. The only time, you would encounter this problem is when you fail to initialize the ArrayList.

Converting primitive wrapper objects to String

The following example shows how to convert objects of primitive wrapper classes to String.

public class PrimitiveWrapperToString {

   public static void main(String[] args) {
     Integer i = new Integer(1);
     Double d = new Double(1.1);
     Float f = new Float(2.2);
     Long l = new Long(13);

     String si = Integer.toString(i);
     String sd = Double.toString(d);
     String sf = Float.toString(f);
     String sl = Long.toString(l);

     System.out.println(si + " " + sd + " " + sf + " " + sl);