Vector and Hashtable

Vector and Hashtable are supposed to be the collection synchronized as part of th e java collection objects. I have a few questions about those two.

In the early days of my development career, I learned that 'Vectors' & 'hashing' SHOULD be used when programming of applications that those that can be accessed simultaneously by multiple users. We use EJB components and we always use vectors and hash tables when return collections of objects of the methods of EJB, inside business methods and inside servlets. Most of my elders advised me not to use all the other collections, leaving a chance to provoke conflict and interference of information. I hesitated to accept this, but I just did what they asked, because I didn't want to take this responsibility.

But now I see that Vector and Hashtable are supposed to be obsolete collections and should probably not be used in new development. So now, I have a question about these.

1. why they were ranked as the ancients?
2. What are the alternatives we have to use instead?
3. should I risk by using other collection objects in an application simultaneously accessible? (information jam, unexpected manipulations on information, etc.).

Thank you!

Knightbeat wrote:
In the early days of my development career, I learned that "vectors" & "hash tables" SHOULD be used when programming applications that those that can be accessed simultaneously by multiple users.

IMHO Vector and Hashtable were replaced in Java 1.2 in 1998 and are inherited classes.

We use EJB components and we always use vectors and hash tables when return collections of objects of the methods of EJB, inside business methods and inside servlets. Most of my elders advised me not to use all the other collections, leaving a chance to provoke conflict and interference of information. I hesitated to accept this, but I just did what they asked, because I didn't want to take this responsibility.

A good decision I would say pragmatic. Personally, I wouldn't return a collection (rather to return data from the collection, the caller must) or send a copy of the collection that does not need to be synchronized.

But now I see that vector and Hashtable are supposed to be obsolete collections and probably should not be used in the development of new. So now, I have a question about these.

I agree with you.

1. why they were ranked as the ancients?

Because interfaces in Java 1.2 such as map and list have been added and the Vector and Hashtable often served when they do not need to be synchronized or when not used with sufficient attention. i.e. the later design requires you to put a reflection more in how you use the collections.

2. What are the alternatives we have to use instead?

In Java 1.2 Collections.synchronizedList/Map/Set etc. have been added, but most recently in Java 5 (2004) the collections of the library of concurrency have been added (if the class is older than that) for example, ConcurrentHashMap, CopyOnWriteArrayList.

If you want to be updated, I would look at the simultaneous collection as well. http://download.Oracle.com/javase/6/docs/API/Java/util/concurrent/package-summary.html

3. should I risk by using other collection objects in an application simultaneously accessible? (information jam, unexpected manipulations on information, etc.).

I would not spend collections between classes. Instead, I would incorporate them, so a collection is used only in a single class and all the possible interactions between threads can be notice by reading this class. Passing a collection between classes you're openning yourself to unexpected interactions. (Unless you can easily read/understand all the code where the collection could be used)

Thank you!

No problem.

Tags: Java

Similar Questions

  • Collections of Vector and Hashtable obsolete?

    Vector and Hashtable are supposed to be the collection synchronized as part of th e java collection objects. I have a few questions about those two.

    In the early days of my development career, I learned that 'Vectors' & 'hashing' SHOULD be used when programming of applications that those that can be accessed simultaneously by multiple users. We use EJB components and we always use vectors and hash tables when returning collections of objects of EJB methods, inside business methods and inside servlets. Most of my elders advised me not to use all the other collections, leaving a chance to provoke conflict and interference of information. I hesitated to accept this, but I just did what they asked, because I didn't want to take this responsibility.

    But now I see that Vector and Hashtable are supposed to be obsolete collections and should probably not be used in new development. So now, I have a question about these.

    1. why they were ranked as the ancients?
    2. What are the alternatives we have to use instead?
    3. should I risk by using other collection objects in an application simultaneously accessible? (information jam, unexpected manipulations on information, etc.).

    Thank you!
    + [To the admins of the forum (to remove one of them if necessary) (: I posted the same section of simultaneity as well)] +.

    Knightbeat wrote:
    Vector and Hashtable are supposed to be the collection synchronized as part of th e java collection objects. I have a few questions about those two.

    In the early days of my development career, I learned that "vectors" & "hash tables" SHOULD be used when programming applications that those that can be accessed simultaneously by multiple users.

    It is false and has always been.

    Most of my elders advised me not to use all the other collections, leaving a chance to provoke conflict and interference of information.

    WTF is 'interference information '? And what specific conflicts they claim will lead to and how?

    The Collections Framework is out with Java 1.2 in 1998. Its classes are unsynchronized by default, but there are methods to provide a synchronized version of each of them. Your elders don't know what they are talking about.

    But now I see that vector and Hashtable are supposed to be obsolete collections and probably should not be used in the development of new.

    Functionally they still work very well. The reason for preferring the ArrayList and HashMap is that these classes were created as part of Collections from the beginning. Vector and Hashtable was modernized in it. Most people use the most recent classes, and I would personally never use the old categories, unless I had to for reasons of backward compatibility. They still work perfectly well.

  • A3 landscape artboard. When the zoom is less than 100%. the appearance of the work (lines) in staircase, I can tell this resolution because something I have to zoom and it disappears. I understand the difference between vector and raster as well... looks

    A3 landscape artboard. When the zoom is less than 100%. the appearance of the work (lines) in staircase, I can tell this resolution because something I have to zoom and it disappears. I understand the difference between vector and raster so... this kind of problem is like when you zoom too in an image and it becomes pixelated... but otherwise...! I have a macbook pro 2012 model, the retina. is my screen resolution. I thought that the apple screen product meet good standards of adobe creative products... Reviews

    Check if the switch between the GPU and CPU makes a difference: Cmd E

    Or turn in the preferences: GPU performance.

  • What is the Differnce between HashMap and HashTable?

    Hi all

    What is the Differnce between HashMap and HashTable?

    I'm confuse. !!


    Thanks to advnce.

    This question is answered in the Javadoc here http://download.oracle.com/javase/6/docs/api/java/util/HashMap.html and here http://download.oracle.com/javase/6/docs/api/java/util/Hashtable.html. The thread to block.

    Published by: EJP on 12/07/2010 13:27

  • Vectors and vectors and storage

    Hi, I'm new to the idea of a persistent storage. But I managed to just simply record a channel... that's all

    I will try to implement vectors with persistent storage.

    I want to however the following questions were answered.

    1. A vector can be stored on other things in addition to the elementary data types? For example a vector can store the Editfields or LabelFields with content?
    2. A vector stores objects; Does that mean that I can create a custom object and then make a vehicle more of one of my custom object? How to make a custom object?
    3. What is casting? What is its use?

    If you look at the doc for PersistentObject, you will find a list of objects that are implicitly persistent - this includes the String and vector.  If you look at the Persistable doc, you will find a list of other objects that are persistable.  If you want to create a persistent object, you can create using or extend them, by ensuring that all of the classes that are added to the object (or collection) implement also Persistable, directly or by implication.

    Note that you must explicitly define an as Persistable class.  If you say

    class MyString extends {String

    }

    then MyString is not persistent.

    I hope that now I understood and answered all of your questions!  Sorry to not do it at the beginning.

  • Vectors and paths in Fireworks | CS6

    I have an illustrator file that has paths and vectors, how do I get this imported in dreamweaver easily?

    You can import vector graphics in SVG format, which is based on XML. However, normally you just convert the vector illustrations in a raster format. Use the save for Web feature in Illustrator and first try the GIF format. He usually does a better job with drawing line than the jpeg format.

  • How to manage all your resources vector and image?

    I intend to reuse the many images and vector art I created. From now on, if I want to reuse an image or a vector, I have to oepn the vector image file and copy/paste. Is there a way faster than that? Is there a manager of that I don't know?

    Thank you!

    File > place

    Open the bridge reduced the size so you can see the canvas of Illustrator and bridge.

    Access one or several folders, you have your assets make the folder a favorite then open this folder in the Bridge

    now, when you need an asset that you can drag and the drop.that is true for any file cables vector Illustrator supports the raster line cables so ot.

    It would be better if Illustrator has the minijonction as Photoshop and ID, but there are some users here who do not like the bridge, because you can always use the finder, no matter how rdidiculous that is in reality.

    Make a feature request, I'm tired of reasoning with some of them. It would make life so much easier, but they do not.

    Otherwise, you must use the finder and which lasts about five or six long IME to treat.

    I'll try to make a video to show how it would be easy with the mini bridge.

  • How to import layouts with vectors and direct type?

    I seem to have met a stumper on basic AE workflow. I would like to implement a workflow where I can set an application designs, then put in AE to animate and control the camera around. My intention is to make graphics like this: http://vimeo.com/25123730 (OK, well, not nearly as slick... yet)

    The difficulty is, if I throw my drawing in Photoshop after I import it, it will allow me to convert the direct type, but the vector shapes are pixelated all and I can't get them as vectors. If I throw in Illustrator, the shapes are net of all vectors, but my type is rasterized. I think that there is something that I have to Miss here.

    What is the solution?

    Missing you something, it's just like that. There is always hope for CS6 and beyond, but for now the only type of "vector", you will get Photoshop of text and the layer, which will be converted to AE masks, clipping masks if the PSD is imported as a composition. However, if you want to get an honest opinion: people obsess too much about this vector stuff. Many times it is not necessary to make it work still a raster image enough size and that's what I see looking at your example. The camera movements are not this extreme that they need excessive detail.

    Mylenium

  • Vectors and PES 10

    PES 10 editable vectors?  Example: I download a vector graphics, stock photography site navigation elements, I want to use some of these on a photo/blog, etc.  Can I do this?  Could not with PSE 7, I was wondering if I should switch to 10 if it can handle the vectors now.

    Thank you very much!

    You have a PSD file created in the 'big' Photoshop.  These layers are actually groups of layers, that PES cannot be changed.

    The price very reasonable items + add-in for PSE allows to separate, edit (and re-group) these layers:

    http://elementsplus.NET/

    Ken

  • What is the difference between vector and LinkedList

    Can someone explain in simple terms for me?

    captfoss wrote:

    jschell wrote:

    user455529 wrote:
    Finally synchronized to start (I don't immediately give him). Did you even check their respective Javadocs? Was there a difference in special feature that you didn't understand?

    I strongly suspect that the poster knows the difference. The alias suggests the identity.

    I thought that Martin Luther King died in the 1960s?

    He hooked a ride on a flying saucer and later contracted to come and be his private Bard Elvis.

  • Selection of savings between ObjectChoiceField and Hashtable

    I managed to save a text using EditField

    {if (profile1Hashtable.ContainsKey ("LastName"))}

    lastName.setText ((String) profile1Hashtable.get ("LastName"));

    }

    So I thought that to save a value (sex selector) would be

    {if (profile1Hashtable.ContainsKey ("Sex"))}

    sexChoiceField.setSelectedIndex ((Integer) profile1Hashtable.get ("Sex"));

    }

     

    But what is the code that I put in the save()?

    Its because I failed at the bis code 'new '.  Here's a corrected line:

    profile1Hashtable.put ("Sex", New Integer (sexChoiceField.getSelectedIndex ()));

  • Java sdk support

    Hello

    can someone tell me up to which version of the java sdk, we can use in blackberry.

    Java BlackBerry os is based on j2me, which is in turn based on java 1.4 (or 1.3?)
    in any case, you cannot use the api collections unless you implement it yourself.
    basically: use vector and hashtable.

  • Question about persistence

    Hello.

    I have a question on the Persistable interface. If I am not mistaken, inside an object persistent all primitive types, arrays of primitive types and vectors containing objects (implementing Persistable) are preserved. What vectors or arrays that contain non-persistent objects? If the attributes of the objects are primitive, they persist or will their references? And what also happens to the objects contained in the Persistable collections like BigVector?

    I have re-read the docs for a while, and I couldn't so Vector and Hashtable are Persistable by default.

    Thanks in advance.

    PD: It seems to me very little natural in Java the fact that an object does not inherit the Persistable interface. So let's say we are programming with Java language updated, don't you think?

    You are right, Vector and HashTable (and a number of other classes) do indicate that they implement Persistable.  I raised it by using the send feedback.

    However, rest assured that they don't.

    The Persistable implementation also appear in a number other standard objects like String.  In addition, I have never tried to persist Boolean, integer or similar items, I feel they will persist well, but it doesn't seem to be any documentation of these two.

    I suggest you use the feedback to present (in the pages of the JavaDoc 5.0 OS) on the request of documentation of the present, as I did.

    I think Simon summed the basic rules.  Each object that is persisted must implement Persistable, otherwise an Exception will be thrown when you try to make persistent object, or collection that contains the object.

    In a specific response to two questions:

    (1) "If these attributes are primitive, they persist or will have their references?

    I think that what is happening is one serialized to of the object is retained, but I did, do you really care.  You are concerned, when you persist an object, the object and all its primitives, and all the objects referenced and all their primitives and all the objects that they reference all their primitives... are persisted.

    (2) "it seems to me very little natural in Java the fact that an object does not inherit the Persistable interface.»

    I think you are suggesting that if A is persistable, then an extension of A should also be persistent.  Under normal circumstances, I would agree, but for Persistable, I disagree.  The current situation, where, by default, extensions are not Persistable seems reasonable to me.  So persistent was inherited, then you would never be able to extend objects in a way that has kept this Persistable attribute.

  • I have a license of an image that is a vector, but it is a vector of flat and cannot be changed with no layers. Are the vectors of Adobe Stock like that?

    When I buy stock of Shutterstock and iStockPhoto vector, it gives me all the layers and is fully editable. I downloaded 2 Adobe Stock vectors, and are flat images, unexpandable with none of the layers. Is this the case for all vector Adobe stock?

    I solved this problem by right-clicking on the image in my library and choosing 'edit picture '. It opens in a have another file, and I can then edit each individual item.

  • With the help of vector graphics with fxml and JavaFX

    HY

    I wonder about the use of vector graphics scalable, svg, files in my project JFX.
    I know how to display the png with an imageview images and who can handle via CSS style (like fx-background-image)
    But for now, I want to add a vector graphic to my scene.
    I'm not shure if I use .ai, .svg or other file formats and how to load that.

    I read on SVGGraph but failed to get the idea behind it
    (and think that's not for files)

    So please can someone tell me how single charge and show a graphic vector and formaterait which should take?

    Ah: A way to make this replaceable graph via CSS style would be nice too ;)

    Thank you

    BR

    This .fx file is probably the old 1.x JavaFX, which is no longer supported for JavaFX 2.x and to my knowledge there is also no converter for this.

Maybe you are looking for