Vector isEmpty() in Java

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

Syntax:

boolean java.util.Vector.isEmpty()

This method tests if this vector has no components.

Parameters: NA

Returns: true if and only if this vector has no components, that is, its size is zero; false otherwise.

Exceptions: NA

Approach

Java

import java.util.Vector;

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

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

        vector.add("Hello");
        vector.add("Java");
        vector.add("C++");
        vector.add("Program");

        System.out.println(vector.isEmpty());
    }
}

Output:

false


No comments:

Post a Comment