Java Vector

java

// Vector: a thread-safe version of ArrayList

Vector<Object> preventableOrNotVector = new Vector<>();
preventableOrNotVector.add(lUsersID);

Vector eventIDs;
eventID = eventIDs.get(i).toString();

.contains

How can we create a empty vector object?

final Vector<Object> preventableOrNotVector = new Vector<>();

How can we add an element to a vector?

preventableOrNotVector.add(lUsersID);

How can we iterate over a vector?

private int getMaxCharacterCount(Vector eventIDs) {
    int maxCharacterCount = 0;
    int characterCount = 0;
    int size = eventIDs.size();
    int i = 0;
    String eventID = "";
    for (i = 0; i < size; i++) {
        characterCount = eventID.length();
        if (characterCount > maxCharacterCount) {
            maxCharacterCount = characterCount;
        }
        eventID = eventIDs.get(i).toString();
    }
    return maxCharacterCount;
}

How can we test to see if the vector contains a certain item?

Use the contains method.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License