Java Arraylist add Example

ArrayList class add method example. This example shows you how to use add method.


ArrayList class add method example.public boolean add(List e) Appends the specified element to the end of this list.

Here is the code

/**
 * @ # Add.java
 * A class repersenting use to add() method of ArrayList class in java.util package
 * version 14 May 2008
 * author Rose India 
 */
import java.util.*;

public class Add {

    public static void main(String args[]) {
        List arrlist = new ArrayList();
        int i = 0;
        String str = "Rose India";

        //Add the specified element to the end of this list.
        arrlist.add(i);
        arrlist.add(str);

        System.out.println("arrlist = " + arrlist);
    }
}

Output
 arrlist = [0, Rose India

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US