title: Adding and setting new object in ArrayList at specific index (JAVA)
body: <p>I made some projects with ArrayList. They have same problem with adding new object. My goal is to add new Object at specific location. For instance, each index hold four strings. </p>
  
  <pre><code>index 0: New York Times, 1234, New York, NY
  index 1: NBCPhiladelphia, X123, Philadelphia, PA
  index 2: FOX News, 0987, Los Angeles, LA
  </code></pre>
  
  <p>Suppose I want to add new one: CNN, 1230, Atlanta, GA. The location will be at index 1. Then other object will move in other index and so on... like this one:</p>
  
  <pre><code>index 0: New York Times, 1234, New York, NY
  index 1: CNN, 1230, Atlanta, GA
  index 2: NBCPhiladelphia, X123, Philadelphia, PA
  index 3: FOX News, 0987, Los Angeles, LA
  </code></pre>
  
  <p>So far, my code seems not work to insert new one. I don't know how to find a way to fix this error.</p>
  
  <pre><code>public static void main(String[] args) {
  ArrayList&lt;NewsTV&gt; newsTVList = new ArrayList&lt;NewsTV&gt;();
  String nameToAdd = "CNN";
      String idToAdd = "1234-123X";
      String cityToAdd = "Atlanta";
      String stateToAdd = "GA";
      int indexToAdd = 6;
  
  ...... //This part, I add objects so don't worry about them.
  
      newsTVList.add(indexToAdd, null);
      insertObject(newsTVList, indexToAdd, nameToAdd, idToAdd, cityToAdd, stateToAdd);
  
  public static void insertObject(ArrayList&lt;NewsTV&gt; np, int index, String n, String id,
                                      String c, String s) {
  
      for(NewsTV news: np) {
          if(np.indexOf(index)) {
              news.setName(n);
              news.setISSN(id);
              news.setCity(c);
              news.setState(s);
          }
      }
  
  }
  </code></pre>