title: Creating a for loop to create multiple objects to add to a graph
body: <p>I'm trying to create a graph. I'm following a tutorial and this is hard coded way of doing it:</p>
  
  <pre><code>GraphView graph = (GraphView) findViewById(R.id.graph);
  LineGraphSeries&lt;DataPoint&gt; series = new LineGraphSeries&lt;DataPoint&gt;(new DataPoint[] {
            new DataPoint(0, 1),
            new DataPoint(1, 5),
            new DataPoint(2, 3),
            new DataPoint(3, 2),
            new DataPoint(4, 6)
  });
  graph.addSeries(series);
  </code></pre>
  
  <p>However, I have data coming in from my database which has already been parsed. I'm trying to feed that data to my graph. My way of doing it partially works, the data is displayed on the x-axis and y-axis but the graph itself is not drawn and I'm not sure why.</p>
  
  <p>This is a small snippet of my code:</p>
  
  <pre><code>    for(int i =0; i&lt;Profit.length; i++){
  Date date = getDate()[i] 
                   series = new LineGraphSeries&lt;DataPoint&gt;(new DataPoint[]{
                          new DataPoint(date, Profit[i])
  
  
                  });
  
  
              }
  
                          graph.addSeries(series);
              System.out.println("GRAPH COMPLETE");
  </code></pre>
  
  <p>I've only shown you the bit that's the problem. It's the loop. I've needed the for loop before <code>graph.addSeries(series)</code> so that the data is first collected. But I've found that doing the hard coded way as shown initially works, but the automated way I`m trying to do it, is only half working.</p>
  
  <p>Can someone please advise me on what I need to do?</p>
  
  <p>EDIT:</p>
  
  <p>I've tried to implement the suggested edits but I'm still getting the same result.</p>
  
  <p><a href="https://i.stack.imgur.com/gyhpu.png" rel="nofollow noreferrer">Graph</a></p>