-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIs_empty.java
More file actions
24 lines (22 loc) · 800 Bytes
/
Is_empty.java
File metadata and controls
24 lines (22 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.ArrayList;
public class Is_empty {
public static void main(String[] args)
{
// creating an Empty Integer ArrayList
ArrayList<Integer> arr = new ArrayList<Integer>(10);
// check if the list is empty or not using fucntion
boolean ans = arr.isEmpty();
if (ans == true)
System.out.println("The ArrayList is empty");
else
System.out.println("The ArrayList is not empty");
// addition of a element to the ArrayList
arr.add(1);
// check if the list is empty or not
ans = arr.isEmpty();
if (ans == true)
System.out.println("The ArrayList is empty");
else
System.out.println("The ArrayList is not empty");
}
}