Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Joshua Cranmer Newsgroups: comp.lang.java.programmer Subject: Re: setSize ArrayList, when will it come? Date: Tue, 09 Aug 2011 16:30:53 -0500 Organization: A noiseless patient Spider Lines: 23 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 9 Aug 2011 21:30:59 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="B3q1fNdvNsCxx/IZ4idKGA"; logging-data="1226"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+yzL/JHODeCbS4fczFM6t6P1ieObXqTD0=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110624 Thunderbird/5.0 In-Reply-To: Cancel-Lock: sha1:c0o95tvL6jVTNZ+wjfUpCKeqk94= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:6926 On 8/9/2011 11:30 AM, Jan Burse wrote: > Joshua Cranmer schrieb: >> There are a fair number of observable differences between Vector and >> ArrayList, even if you exclude the part about synchronized methods. > What are you refering to? Can you elaborate on your thoughts. Anything reflective is a dead giveaway, and I'm pretty sure that the two classes have slightly different sizes, so you could observe differences in memory characteristics. More seriously, the Collections API tweaked some method names differently, so there are a few methods in Vector which are kept around for legacy use (addElement, e.g.). In general, an ArrayList is a list that happens to be backed by an array. A Vector is a synchronized, automatically-growing array that leaks details about its array all over the place; it was shoehorned into the Collections API upon introduction to allow for a more gradual, correct migration. -- Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald E. Knuth