Java Collection Tutorial - Java Vector.isEmpty()








Syntax

Vector.isEmpty() has the following syntax.

public boolean isEmpty()

Example

In the following code shows how to use Vector.isEmpty() method.

//from   w w  w .  j  a va 2s  .  co  m
import java.util.Vector;

public class Main {
   public static void main(String[] args) {
           
      Vector  vec = new Vector  (4);
      
      System.out.println("The vector is empty: "+vec.isEmpty()); 

      vec.add(4);

      System.out.println("The vector is empty: "+vec.isEmpty()); 
   }     
}

The code above generates the following result.