Case of Missing Runtime Error
I have this program when I have initialized with a generic type of Integer but not declared it with a generic type of Integer , when I try to add a String I don't get a compile error as expected , but I don't even get a runtime error when I run , what do you think is happening here ?
//Declaration with no ArrayList<Integer> al
ArrayList al = new ArrayList<Integer>();
al.add(45);
al.add("This string should not be here");
try
{
for (Iterator<Integer> i = al.iterator();i.hasNext();)
System.out.println("al[" + i + "]:" + i.next());
} catch (Exception e)
{
System.out.println("Message:" + e.getMessage());
}

