Java - Array List and Array Class in Collection and Collections (Example and Methods) - Java2021 : Online Tutorials Hub

Java2021 : Online Tutorials Hub

JAVA | Advance Java | MySQL | Data Structure | Git | HTML | CSS | JS

Latest

Post Top Ad

Tuesday, April 21, 2020

Java - Array List and Array Class in Collection and Collections (Example and Methods)

Java - Array List and Array Class in Collection and Collections (Example and Methods)


package collection_examples;
import java.util.*;
public class ArrayListExample {
    public static void main(String[] args) {

    ArrayList array1=new ArrayList();
    array1.add("Apple");
    array1.add("Ball");
    array1.add("Cat");
    ArrayList array=new ArrayList();
    array.add("Ravi");
    array.add("Kumar");
    array.add("Sagar");
    //array.remove("Ravi");
    array.add(2,"ravi");
    //array.removeAll(array);
    array.addAll(array1);
        //System.out.print(array);
        Iterator it=array.iterator();
        while (it.hasNext()){
            System.out.println(it.next());
        }
    }
}


Sorting and Searching Programs
Start with your Choice
-Important Programs for Freshers
Learn Pattern Programs 
Click to learn Array Programs
Click to Learn MySQL 
for any complaint regarding my Blog please visit contact us page and write what problem you have!

No comments:

Pages