The below program produced the 'java.lang.OutOfMemoryError' in couple of seconds when i ran in my machine. :-)
public class OutOfMemory {
static int count = 0;
static ArrayList aString = new ArrayList();
static String string;
public static void main(String[] args) {
while (true){
int i=0;
string = new String("Achyuth");
aString.add(string);
aString.addAll(aString);
System.out.println(count++ +" "+aString.size());
}
}
}