• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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: 23958
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.
 
Grow your own food... or this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic