- code
import java.util.*;
public class TestCollection {
public static void main(String[] args) {
// TODO Auto-generated method stub
ArrayList<String> l=new ArrayList<String>();
l.add("Dara");
l.add(new String("ABC"));
l.add(1, "SOK");
System.out.println("out of l");
for (String i:l)
{
System.out.println(i);
}
System.out.println("\nsize of l");
int n =l.size();
System.out.println(n+"");
System.out.println("\nout index 2");
System.out.println(l.get(2));
l.set(2, "SALA");
System.out.println("\nAtfer Set index 2");
System.out.println(l.get(2));
System.out.println("\nout of l");
for (String i:l)
{
System.out.println(i);
}
System.out.println("\nout index 1 method get");
String t=l.get(1);
System.out.println(t);
Object []k=l.toArray();
System.out.println("\n\nout k copy from l");
for (Object i:k)
{
System.out.println(i.toString());
}
System.out.println("\nout index 1 method tostring");
String c =l.toString();
System.out.println(c);
System.out.println("\nremove index 1" +"'Sok'");
l.remove(1);
System.out.println("\nout l");
for (String i:l)
{
System.out.println(i);
}
}
}
No comments:
Post a Comment