Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Nov 20th, 2018 76 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. The fundamental differences between Array and ArrayList are the same as those between Array and Vector. Both ArrayList and Vector are generic wrapper classes containing a private array instance, whose methods to add or remove elements of the private array will increase or decrease respectively the size of the array (and therefore the memory it requires). This is done by checking when adding or removing items whether the array is of the appropriate size given the number of elements it contains, create a new array of an appropriate size, copying each element to the new array, and updating its private array property to reference the new array. They also allow the user to preemptively grow or shrink the array as a performance optimization if the user can anticipate how many elements will be added, or if there are no more elements to add.
  2.  
  3. The primary practical difference between Vectors and ArrayLists is in their use in multithreaded programs. Vectors are “synchronized”, meaning that their mutating methods are all implemented with the “synchronized” keyword, and so are guaranteed to work in multithreaded programs without errors. The synchronized keyword does cause a performance penalty, so if the built-in synchronized methods are unnecessary for the program being written, the program may run slower than with an ArrayList used in place of a Vector. A program using ArrayList may still make use of the synchronized keyword.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top