11:41 pm - Saturday August 18, 2018

ArrayList Example Program for isEmpty()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*@author :CandidJava.com
*@descriptions : This program explain the function and use of
boolean isEmpty().It is used to check whether list is empty or not
*/
import java.io.*;
import java.util.*;
public class ArrayListIsEmpty
{
public static void main(String arg[])throws Exception
{
ArrayList al=new ArrayList();//to create object for ArrayList class
ArrayList al1=new ArrayList();//to create object for ArrayList class
al.add("a");//to add an element in arrayList
al.add("b");//to add an element in arrayList
al.add("c");//to add an element in arrayList
Boolean b=new Boolean(al.isEmpty());//to check whether list is empty or not
Boolean b1=new Boolean(al1.isEmpty());//to check whether list is empty or not
System.out.println(al);
System.out.println(b);
System.out.println(al1);
System.out.println(b1);
}
}

Output:
[a, b, c]
False
[]
true

BACK

Filed in: Z-A All Java Codes

Comments are closed.