|
|
|
|
|
by vbezhenar
86 days ago
|
|
No, in the example they provided, programmer wrote obviously stupid code. It has nothing to do with necessity: Long sum = 0L;
for (Long value : values) {
sum += value;
}
I also want to highlight that there are plenty of collections utilizing primitive types. They're not generic but they do the job, so if you have a bottleneck, you can solve it.That said, TBH I think that adding autoboxing to the language was an error. It makes bad code look too innocent. Without autoboxing, this code would look like a mess and probably would have been caught earlier. |
|
But that's the thing, in other languages you don't need a workaround to work on primitives directly.