Write a Java program to empty an array list

Write a Java program to empty an array list


In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..


Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

  1. import java.util.ArrayList;
  2. import java.util.Collections;
  3. public class Javacollectionexcercise {
  4. public static void main(String[] args) {
  5. ArrayList<String> Stringslist1= new ArrayList<String>();
  6. Stringslist1.add("Audi");
  7. Stringslist1.add("BMW");
  8. Stringslist1.add("Bugatti");
  9. Stringslist1.add("Ford");
  10. Stringslist1.add("Honda");
  11. Stringslist1.add("Hyundai");
  12. System.out.println("Original array list: " + Stringslist1);
  13. Stringslist1.removeAll(Stringslist1);
  14. System.out.println("Array list after removing all elements "+ Stringslist1);
  15. }
  16. }


java techstudy.org


Related Topics


Popular Posts


Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.