title: for each inside a for each - Java
body: <pre><code>for (Tweet tweet : tweets) {                
      for(long forId : idFromArray){
          long tweetId = tweet.getId();
          if(forId != tweetId){
              String twitterString = tweet.getText();
              db.insertTwitter(twitterString, tweetId);
          }
      }
  }
  </code></pre>
  
  <p>My code won't run pass the first for{} loop, that's why idFromArray is empty since I don't add anything there until a tweet is has been added to the database.</p>
  
  <p>And even if there is something in the array it loops the whole thing twice (DUH! Since I have two loops) which makes the database very bloated with the same tweets.</p>
  
  <p>It is not a simple compare of the two tweets id and simply ignore the ones with the same id.</p>
  
  <p>I'm pretty certain there is a really simple solution to this problem, but I still can't wrap my head around it. Anybody?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>What I want is the code to ignore the the tweetId that already is in the database.
  And just insert the tweets that is not in the database.</p>
  
  <p>I don't think I should have two for-loops, I think the second loop should be replaced with something? (or maybe I'm wrong?)</p>