title: difference between add and set in arraylist
body: <p>I need your help will you please tell me what difference between add() and set() in ArrayList. I Wrote a program uising set() and add() try to find out try to fing find out what are differences I search on the net but could not find my suitable answer </p>
  
  <pre><code>public class arraylistDemo 
  {
  
      public static void main(String[] args) throws Exception
  {
  
          ArrayList al = new ArrayList();
          al.add(10);
          al.add("A");
          al.add("B");
          al.add(null);
  
  
          al.set(0, 11);
          System.out.println("After Add "+""+al);
  
          al.add(1, "AA");
          System.out.println("Using add method"+ " " +al);
  
          al.set(1, "AA");
          System.out.println("Using set method"+ " " +al);
      }
  
  }
  </code></pre>
  
  <p>O/P- Using add method [11, AA, B, null]
  Using set method [11, AC, B, null]</p>