Javatpoint Logo
Javatpoint Logo

Java Vector isEmpty() Method

The isEmpty() method of Java Vector class is used to check if this vector has no components. It returns true if the vector is empty, otherwise returns false.

Syntax

Following is the declaration of isEmpty() method:

Parameter

This method does not accept any parameter.

Return

The isEmpty() method returns true if and only if this vector has no components, otherwise returns false.

Exceptions

NA

Compatibility Version

Java 1.2 and above

Example 1

Test it Now

Output:

Vector:  [Java, Ruby, Android, Python]
Is the Vector empty? = false
Vector after clear(): []
Is the Vector empty? = true

Example 2

Test it Now

Output:

Vector: []
Is the Vector empty? = true

Example 3

Test it Now

Output:

Vector isEmpty() before? false
Vector isEmpty() after ? true

Next TopicJava Vector





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback

  • Send your Feedback to feedback@javatpoint.com

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA