开发者

is there anybody out there still using Vector(instead of Collections.synchronizedList(List list)/CopyOnWriteArrayList)? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

I wonder why this question still exists in 2011,J2SE 1.2 wa开发者_如何转开发s released in Dec 98 with Collections framework.is there anybody out there still using Vector(unless you are writing client for interface that returns Vector)?


Java 5.0 introduce the concurrency collections in 2004, and many people don't appear to be using these instead of Collections.synchronizedList(). They are not a direct replacement, sometimes it is better to use the JDK 1.2 or 5.0 collections but it surprised me how often people don't make good use of them.


I haven't used Vector or Hashtable in many years now.


Legacy collection classes such as Vector and Hashtable still exist because Sun (and now Oracle) always deemed it extremely important to keep Java backwards compatible. They never remove old stuff from the standard Java API, because that would break old programs.

The real question should be: Why did Sun (or Oracle) not make the legacy collection classes deprecated?

There isn't a clear technical reason why the old classes are not deprecated. Probably this is because other parts of the API are still using those legacy classes and Sun / Oracle don't want to bother users too much with deprecation warnings during compilation.

Anyway, never use those legacy classes unless you really have to (for example because you're dealing with an old API).


I use Vector frequently mostly with Swing. I have a lot of applications that use classes like DefaultTableModel that are really simple to use if you have data in a Vector. There are ways around this, but I like to keep simple as it does not hinder performance.

However, any other time I need a list I do not use Vector.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜