Answer the question
In order to leave comments, you need to log in
Is boxing done when adding a primitive to a collection in Java?
In C#, you can use generic collections (for example, List ) and when you add an int value to such a collection, there will be no boxing. But in Java, for some reason, it is impossible (or is it still possible?) to set a primitive into the argument type, but only their wrapper classes (for example, Integer) are allowed. Well, the question itself, it turns out that the use of generic collections in java does not affect performance in any way (because primitive values are packed anyway), and their main use is only in type safety?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question