4:15 am - Thursday July 19, 2018

ArrayList Example Program for clear()

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
void clear().It is used to remove all elements in list */
import java.io.*;
import java.util.*;
public class ArrayListClear
{
public static void main(String arg[])throws Exception
{
ArrayList E=new ArrayList();//to create object for ArrayList class
E.add(12);//to add an element in arrayList
E.add(10);//to add an element in arrayList
E.add(6);//to add an element in arrayList
System.out.println(E);
E.clear();//to remove all elements in list
System.out.println("after given clear():");
System.out.println(E);
}
}	

Output:
[12,10,6]
after given clear():
[ ]

BACK

Filed in: Z-A All Java Codes

Comments are closed.