Re: Issue With ArrayList



On Thu, 6 Nov 2008 22:08:57 -0800 (PST), jagadesh
<jagadesh.manchala@xxxxxxxxx> wrote, quoted or indirectly quoted
someone who said :


ArrayList my=new ArrayList(10);

works faster that ArrayList my=new ArrayList(10);

I think you meant:

ArrayList my = new ArrayList(10);
works faster than
ArrayList my = new ArrayList();

That is not true.

However:
ArrayList my = new ArrayList(100);
works faster than
ArrayList my = new ArrayList();
If you have 100 elements. However if you have only 10, then
ArrayList my = new ArrayList();
works faster.

new ArrayList() is just shorthand for new ArrayList(10).
They have exactly the same meaning.

Normally you specify the content type e.g.

ArrayList<String> my = new ArrayList<String>(100);
--
Roedy Green Canadian Mind Products
http://mindprod.com
Your old road is
Rapidly agin'.
Please get out of the new one
If you can't lend your hand
For the times they are a-changin'.
.



Relevant Pages

  • Re: new JDK 1.7.0_04 and 1.6.0_32
    ... I have written some hand-holding notes at ... Roedy Green Canadian Mind Products ...
    (comp.lang.java.programmer)
  • Re: Clearing the cmd window
    ... Roedy Green Canadian Mind Products ... "The most significant trend in the US industry has been the decline in the amount ...
    (comp.lang.java.help)
  • Re: Java serialization over network
    ... Roedy Green Canadian Mind Products ... "Danish studies of 10,000 birds killed revealed that almost all died in ...
    (comp.lang.java.programmer)
  • Re: [Popupmenu]What is the use of Label and Name
    ... Roedy Green Canadian Mind Products ... "Out of 135 criminals, including robbers and rapists, 118 admitted that when they were children they burned, hanged and stabbed domestic animals." ...
    (comp.lang.java.help)
  • Re: How to (efficiently) write an int array into a file ?
    ... and I was talking about DataOutputStream. ... You seemed to be stubbornly insisting on things that you surely knew ... Roedy Green Canadian Mind Products ...
    (comp.lang.java.help)