+ 1

What are the differences between these two declarations?

List<Integer> L = new ArrayList<>(); ArrayList<Integer> AL = new ArrayList<>(); In what way they are different OR are they same?

15th Oct 2019, 11:08 AM
ta11_g33k
ta11_g33k - avatar
5 Answers
+ 3
I agree with your answer, but as I saw in many collections tutorials they use the List instead of ArrayList as a reference object thats why it bothered me ask this question. Thanks for the answer
15th Oct 2019, 2:54 PM
ta11_g33k
ta11_g33k - avatar
+ 1
https://stackoverflow.com/questions/147468/why-should-the-interface-for-a-java-class-be-preferred Look for the suggested answer in the above link, I found this as much more detailed explanation.
15th Oct 2019, 3:57 PM
ta11_g33k
ta11_g33k - avatar
+ 1
https://www.javaworld.com/article/2073649/why-extends-is-evil.html This blog post explains why interfaces are more important than Classes.
16th Oct 2019, 5:36 AM
ta11_g33k
ta11_g33k - avatar