Friday, 23 August 2013

Java cast is it better imperative or programmatic way?

Java cast is it better imperative or programmatic way?

I have a doubt, I have seen that there are two way to cast an object in java:
List<Object> l = new ArrayList();
ArrayList<Object> first = (ArrayList<Object>) i;
ArrayList<Object> second = ArrayList.class.cast(i);
Which is better and why?

No comments:

Post a Comment