Is there any downside or problem potential to change the Java compiler to automatically cast? In the example below the result of list.get(0) would automatically be casted to the type of the variable hi.
List list = new ArrayList();
list.add("hi");
String hi = list.get(0);
I know that generics allow you to reduce casting but they do so at the expense of making declaration more difficult. To me, the benefit of generics is that they allow you to have the complier enforce more rules -- not they they reduce casting (but I haven't used them much so I am somewhat uninformed). This proposal would only reduce the amount of code to type, not move it to another place. Also there are instances where generics can't be used because a collection can have different objectis. If that "looks too surprising" based on current usage maybe there could be a syntax tweak to use it.
From: http://jamesjava.blogspot.com/2007/01/automatic-casting.html