import java.util.*;
class Collection_ArrayList_3
{
public static void main(String[] args)
{
Emp e1=new Emp(111,"AK");
Emp e2=new Emp(222,"Singh");
Emp e3=new Emp(333,"Software Engineer");
Emp e4=new Emp(444,"Web Applications");
ArrayList<Emp> al1=new ArrayList<Emp>();
al1.add(e1);
al1.add(e2);
ArrayList<Emp> al2=new ArrayList<Emp>();
al2.addAll(al1);
al2.add(e3);
al2.add(e4);
System.out.println(al2.contains(e1));
System.out.println(al2.containsAll(al1));
al2.remove(e1);
System.out.println(al2.contains(e1));
System.out.println(al2.containsAll(al1));
for(Emp e:al2)
{
System.out.println(e.id+"------"+e.name);
}
}
}
Thanks
Happy programming!
class Collection_ArrayList_3
{
public static void main(String[] args)
{
Emp e1=new Emp(111,"AK");
Emp e2=new Emp(222,"Singh");
Emp e3=new Emp(333,"Software Engineer");
Emp e4=new Emp(444,"Web Applications");
ArrayList<Emp> al1=new ArrayList<Emp>();
al1.add(e1);
al1.add(e2);
ArrayList<Emp> al2=new ArrayList<Emp>();
al2.addAll(al1);
al2.add(e3);
al2.add(e4);
System.out.println(al2.contains(e1));
System.out.println(al2.containsAll(al1));
al2.remove(e1);
System.out.println(al2.contains(e1));
System.out.println(al2.containsAll(al1));
for(Emp e:al2)
{
System.out.println(e.id+"------"+e.name);
}
}
}
Thanks
Happy programming!
No comments:
Post a Comment