Stating the concrete implementation in java

1) should I state the concrete implementation of an object on creation?


list<> l1 = new LinkedList<>();


LinkedList<> l1 = new LinkedList<>();

If I chose LinkedList (or any other implementation for the matter)

I can probably use more methods: list methods are subset of linked list methods.

If I chose list I can change the implementation latter on.


2) What about those diamond operators? which option is recommended?

list<> l1 = new LinkedList<>();

list<> l2 = new LinkedList();

list l3 = new LinkedList<>();

list l4 = new LinkedList();

If I chose to remove the operators I don’t have to state...

Read More »

By: StackOverFlow - Wednesday, 9 January

Related Posts