Source: CodeSpeedy Click to know more Check if an ArrayList is empty or not
import java.util.ArrayList;
public class arraycheck {
public static void main(String args[]){
ArrayList<Integer> list=new ArrayList<Integer>();
if(list.size()==0){
System.out.println("Its Empty");
}
else
System.out.println("Not Empty");
}
}
Output:
run:
Its Empty
BUILD SUCCESSFUL (total time: 0 seconds)