Wrappers of primitive types in arraylist vs arrays

Posted by ismail marmoush on Stack Overflow See other posts from Stack Overflow or by ismail marmoush
Published on 2010-12-29T20:45:27Z Indexed on 2010/12/29 20:55 UTC
Read the original article Hit count: 281

Hi, In "Core java 1" I've read

CAUTION: An ArrayList is far less efficient than an int[] array because each value is separately wrapped inside an object. You would only want to use this construct for small collections when programmer convenience is more important than efficiency.

But in my software I've already used Arraylist instead of normal arrays due to some requirements, though "The software is supposed to have high performance and after I've read the quoted text I started to panic!" one thing I can change is changing double variables to Double so as to prevent auto boxing and I don't know if that is worth it or not, in next sample algorithm

public void multiply(final double val)
    {
        final int rows = getSize1();
        final int cols = getSize2();
        for (int i = 0; i < rows; i++)
        {
            for (int j = 0; j < cols; j++)
            {
                this.get(i).set(j, this.get(i).get(j) * val);
            }
        }
    }

My question is does changing double to Double makes a difference ? or that's a micro optimizing that won't affect anything ? keep in mind I might be using large matrices.2nd Should I consider redesigning the whole program again ?

© Stack Overflow or respective owner

Related posts about java

Related posts about Performance