validation list empty java

Solutions on MaxInterview for validation list empty java by the best coders in the world

showing results for - "validation list empty java"
Nila
04 Aug 2019
1public class ArrayListExample 
2{
3    public static void main(String[] args) 
4    {
5        ArrayList<String> list = new ArrayList<>();
6         
7        System.out.println(list.isEmpty());     //true
8         
9        list.add("A");
10         
11        System.out.println(list.isEmpty());     //false
12         
13        list.clear();
14         
15        System.out.println(list.isEmpty());     //true
16    }
17}
18