performance - In Java, should Integer object be preferred over int primitive (same for other numeric types)? -


ok, understand integer wrapper class. concern avoiding use "wrapper", there might micro-optimization in execution time when using primitive ints variables.

my question regarding, integer object 1 should prefer use, specially in programs required have great performance(with great mean, heavy duty, o(n^n) algorithms, ones take days).

also, same case double vs double, float vs float , etc.

you should prefer using primitives whenever can. otherwise wouldn't exist. developers of java made effort in developing (for java 8) streams support primitive types (intstream, longstream, doublestream), won't have pay performance penalty of multiple boxings , unboxings pay when using streams of reference types wrapper classes.

the wrappers cases in have no choice (for example, can't put primitive types directly in collection).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -