title: Spark: Loop through JavaRDD Tuple - Java
body: <p>I am trying to loop through an JavaRDD with a tuple however I am having some issues on how exactly to loop through the JavaRDD properly and set my rdd_value equal to the tuple's contained in rdd_array at whatever the b iterator counter value is.  </p>
  
  <p>Here is my code</p>
  
  <pre><code>//JavaRDD that contains Tuples
  JavaRDD&lt;Tuple5&lt;Long, String, Float, Float, String&gt;&gt; rdd_array
  
  //For loop to loop through rdd_array
  for (int b=0;b&lt;rdd_array.count();b++){
  
          //Need help on this line, how do I set rdd_row equal to the tuple5 in rdd_array
          Tuple5&lt;Long, String, Float, Float, String&gt; Value = rdd_array.;
          String id=Value._1().toString();
          String text=Value._2().toString();
          String negative_tweets=Value._3().toString();
          String positive_tweets=Value._4().toString();
          String score_tweets=Value._5().toString();
  System.out.println(id+text+negative_tweets+positive_tweets+score_tweets)
  
  }
  </code></pre>
  
  <p>Edit:
  Guys, I am really trying here, took zero323 advice for a foreachloop on the JavaRDD receiving the error cannot resolve method.</p>
  
  <pre><code>rdd_array.foreach(new Function&lt;Tuple5&lt;Long, String, Float, Float, String&gt;, Void&gt;(){
              @Override
              public Void call(Tuple5&lt;Long, String, Float, Float, String&gt; rdd){
                  String id=rdd._1().toString();
                  String text=rdd._2().toString();
                  String negative_tweets=rdd._3().toString();
                  String positive_tweets=rdd._4().toString();
                  String score_tweets=rdd._5().toString();
  
                  System.out.println(id+text+negative_tweets+positive_tweets+score_tweets);
                  return null;
              }
          });
  </code></pre>