Maybe it's because there's no concern there.
It ’s an extreme phrase,
As long as the user guarantees the interface
I'm not interested in the processing cost of List <T> :: size ()
.
It's not a reason why you have to list it There is no clear reason to be so conscious.
As a result, it's enough, so List is fine. Therefore, it is assigned to List.
Of course, if it is a commercial service, I think it should be verified by PoC or performance test. It is necessary to verify whether the usage was correct in another process. I have no intention of recommending coding that it should work.
Also, since the Stream API was added, the chances of writing new ArrayList <> ()
have decreased.
It may be all right now.
~~ It's like burning ~~ I'd be happy if you could give us various opinions such as objections and counterarguments.
When I was watching the buzzword on twitter earlier this week, a coffee shop in the city center was on fire.
From the flow of digging deeply into what everyone has and what kind of impression they have When I noticed, I was investigating the characteristics of Kramer. (If you follow the Wikipedia link, it feels like you'll reach the universe at the end for some reason.)
At that time, in a Java article with a slightly burning comment section, why
sample1.java
ArrayList<T> list = new ArrayList<>();
not,
sample2.java
List<T> list = new ArrayList<>();
I noticed the question, "Is it?"
The questioned side
--There is no such code on git or OSS, right?
The person who asked the question
――I do it for no reason because it is religious
I was writing that.
From the rough way of the comment section At first, I said, "There are some types like this ..." Gradually, I thought, "But surely ... why?" I wanted to output "How would I answer the same question?"
Now that person is not a Kramer I am grateful for the opportunity to question the code I was casually writing.
I will not give you a name, but I would like to take this opportunity to thank you.
Recommended Posts