import java.util.*;
public class ArrayList_Operation_3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<Integer> a = new ArrayList<>();
for(int i=0 ; i<20 ; i++)
{
Random rand = new Random();
int n = rand.nextInt();
n = rand.nextInt(10);
a.add(n);
}
Iterator arr = a.iterator();
while(arr.hasNext())
{
int p = (int)arr.next();
System.out.print(p+" ");
}
for(int i=0;i<arr.size();i++)
{
if(arr.get(i)==5)
{
arr.remove(i);
}
}
for(int i=0 ; i<3 ; i++)
{
Random rand = new Random();
int n = rand.nextInt();
n = rand.nextInt(10);
a.add(4+i,n);
}
}
}