Why is vector obsolete in java




















Thank you. I didn't mean this post to be exhaustive on the possible alternatives, but I've added it to the options none the less. Saturday, 20 October Vector Deprecated? Someone asked me to explain a comment of mine where I mentioned that the Vector class isn't used much any more. Storing a pointer in a container does not define any kind of ownership of the pointer.

Thus the container does not know the semantics of desctruction and copy operations. When the elements are being removed from the container the container is not aware how to properly destroy them, when a copy operation is performend no ownership semanctics are known.

Of course, you can always handle these things by yourself, but then still a chance of human error is possible. Another thing to mention is that containers are divided into non-intrusive and intrusive contaiers - they store the actual provided object instead of a copy so it actually comes down to a collection of pointers.

Non intrusive pointers have some advantages, so you can't generalize that pointers in a container is something that should be avoided in all times, still in most cases it is recommended. Exception handling is a hard topic regardless of whether exceptions are classes or interfaces. I actually suspect it would make it harder on Java programmers if they have to order their catch blocks based on arbitrary interfaces rather than on class hierarchies.

In theory, yes. In practice, no. ArrayList are not synchronized while Vector are. No way Vactor will become obsolete.

And yes you can use Vector of Vector. JTable use them. In short, don't use Vectors unless you are tied to an API which forces you to use it. Also, don't rely on synchronized collections when it comes to handling race conditions; they synchronize individual calls and not logical calls which you actually should have synchronized. I will have to look at the List Collections.

I have wrote a rough draft of a List that is loaded with DateTimes. From each element I can extrapolate three pieces of data that need to be kept together and synchronized with related data from a record.

Some list will not guarantee everytning will be kept in order. The whole operation is to end up with several data types to be turned into strings and used to query and insert in a db.

Thanks for the info and I will end this post saying I am going to explore the Enumeration maybe I will find that they are the solution.

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge. In Java8 Vector's source, there is no depracated notice. But otherwise, no Vector works well. Improve this answer. Walfrat Walfrat 3, 11 11 silver badges 26 26 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.

The Overflow Blog. Does ES6 make JavaScript frameworks obsolete?



0コメント

  • 1000 / 1000