• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Differentiate ArrayList and Vector

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can any please explain what is the difference between ArrayList and Vector?
I know thay Vector is synchronized and ArrayList is not synchronized. Can anybody elaborately explain this difference?
Is there any other difference apart from this one?


Thanks.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The Vector class was one of the earliest of collections available in Java, released with Java 1.0. The ArrayList class was released as part of the Java Collection Framework, some time later -- I am thinking with Java 1.2.

Some work has been done with Vector to integrate it with the framework, such as having it implement List, and support Iterator, but it also must support the old API, for backward compatibility purposes. As such, it doesn't seem to fit exactly with the framework -- and also seems to be duplicated by other collections in the framework.

Henry
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vector is introduced in JDK1.0 and ArrayList is introduced in JDK1.2 . Simple *google* help you
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Henry Wong wrote:
The Vector class was one of the earliest of collections available in Java, released with Java 1.0. The ArrayList class was released as part of the Java Collection Framework, some time later -- I am thinking with Java 1.2.


you beat me though , we both pointed out the same thing
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The old collection classes from Java 1.0 are synchronized. Read Synchronized Methods in Sun's Java Tutorials if you want to learn what sychronization is for.

When the new collection classes were added in Java 1.2, the language designers realized that most of the time you don't need synchronization. But synchronization does add some performance overhead. So they left out the unnecessary synchronization in the new collection classes. If you really need synchronization, you can add it by wrapping your ArrayList using the method Collections.synchronizedList(...), or by using the specialized collection classes from the package java.util.concurrent.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic