0% found this document useful (0 votes)
4 views

First Java Coolection Code (1)

Uploaded by

genetgetahun202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

First Java Coolection Code (1)

Uploaded by

genetgetahun202
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

package javacolls;

import java.util.*;

public class JavaColls {

public static void main(String[] args) {


ArrayList all=new ArrayList();
all.add("x");
all.add('h');
all.add("go");
all.add("alexoo");
all.add("baby");
all.add("gaga");
System.out.println("array holds"+all);
all.set(2,"tiktoke");
System.out.println("array after set"+all);
System.out.println(all.contains("alexoo"));
System.out.println(all.size());
all.remove("alexoo");
System.out.println("after removing alexoo"+all);
System.out.println(all.get(2));
System.out.println("display arry by using for loop");
for(int i=0;i<all.size();i++)
{
System.out.println(all.get(i));
}
System.out.println("display arry by using for each loop");
for( Object e:all)
{
System.out.println(e);
}
System.out.println("display arry by using ITERATORS");
Iterator it=all.iterator();
while(it.hasNext())
{
System.out.println(it.next());
}
}

You might also like