How can I check if a list is empty? If so, the system has to give a message saying List is empty. If not, the system has to give a message saying Li
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 list=new ArrayList();
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)