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.


/* www  .  j a va  2 s  .c o  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.