Remove All Items From a List Example
- /*
- Remove All Items From a List Example
- This java example shows how to remove all items from a list
- using removeAll method of AWT List class.
- */
- import java.applet.Applet;
- import java.awt.List;
- /*
- <applet code="RemoveAllItemsFromAList" width=200 height=200>
- </applet>
- */
- public class RemoveAllItemsFromAList extends Applet{
- public void init(){
- //create a list
- List list = new List(5, true);
- //add items to a list
- list.add("One");
- list.add("Two");
- list.add("Three");
- list.add("Four");
- list.add("Five");
- list.add("Six");
- list.add("Seven");
- //add list
- add(list);
- /*
- * To remove all items from the list, use
- * void removeAll()
- * method.
- */
- list.removeAll();
- }
- }
Example Output




