Vector add(K) in Java

add(K): This method is available in java.util.Vector class of Java.

Syntax:

boolean java.util.Vector.add(K e)

This method takes one argument. This method appends the specified element to the end of this Vector.

Parameters: One parameter is required for this method.

e: the element to be appended to this Vector.

Returns: true.

Exceptions: NA

Approach

Java

import java.util.Vector;

public class Vectoradd {
    public static void main(String[] args) {

        Vector<String> vector = new Vector<>();

        System.out.println(vector.add("Hello"));
    }
}

Output:

true


No comments:

Post a Comment