Community
Participate
Working Groups
2 unnecessaries casts are not detected in the following method : private List test() { List l = new ArrayList(); l.add("aaa"); Object o = ((ArrayList)l).get(0); return (ArrayList)l; }
This cast is not unnecessary in the sense it is altering the generated classfile. With cast, you invoke: ArrayList#get(...), without it you invoke: List#get(...). Thus it is not equivalent, and the compiler tolerates it.