title: i want to count words in java and use every word in class
body: <p>I have this code it works for a single word, but I want it to work for more than one word, like a counter that sends every word in a textfield.</p>
  
  <p>My code is : </p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
  
           ArabicStemmer Stemmer=new ArabicStemmer();
           String ArabicWord=jTextField1.getText().toString();
           jTextField2.setText(String.valueOf(Stemmer.stemWord(ArabicWord)));
  
      }        
  </code></pre>
  
  <p>I can't add the answer right now, but I found out by myself. Here is my new code for anyone who has the same issue:</p>
  
  <pre><code>private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
  
          String finalResult="";
           String ArabicWord =jTextField1.getText().toString();
           for (String retval: ArabicWord.split(" ")){
               ArabicStemmer Stemmer=new ArabicStemmer();
               finalResult= finalResult +" " +  String.valueOf(Stemmer.stemWord(retval));
           }
     jTextField2.setText(finalResult);         
  
  }    
  </code></pre>