Java J2ee Tutorials

Simple ArrayList Example | ArrayList Sample

Wednesday, March 21, 2012

  • package arraylistexample;

  • import java.util.ArrayList;
  • /**
  • * SimpleArrayListExample This is example for simple arraylist. It shows how
  • * to create an array list and also add the value into arraylist as well as
  • * reterive it
  • */
  • public class SimpleArrayListExample {
  • public static void main(String[] args) {
  • //creating arraylist
  • ArrayList al = new ArrayList();
  • //adding values into arraylist
  • al.add(1);
  • al.add(2);
  • al.add(3);
  • //Fetching the values from arraylist.
  • for(int i=0;i
  • System.out.println(al.get(i));
  • }
  • }
  • }
  • Free Career Predictions

    0 comments:

    Post a Comment