Posted by: Sourav | August 6, 2012

ArrayList or dynamic array example in Java


import java.util.ArrayList;
public class Arraylist{
    
    public static void main(String[] args){
        
        
        //System.out.println(“Hello!!!!!!!!!”);
        
        
        ArrayList sourav=new ArrayList();
        
        String name1=”Sougata”;
        String name2=”Soumalya”;
        sourav.add(name1);
        sourav.add(name2);
        
        System.out.println(sourav.get(0));
         System.out.println(sourav.get(1));
         
         sourav.remove(name1);
         System.out.println(sourav.get(0));
         //sourav.remove(1);
         //System.out.println(sourav.get(0));
         
         
         
    }
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: