title: Count how many times a string repeats itself SCALA
body: <p>Hi I´m trying to get the number of times an artist name repeats in some years for this I have this</p>
  
  <pre><code>var artists=Array.ofDim[String](994,2)//artist,year
  var artists2=Array.ofDim[String](250)//artist name
  var artists3 = Array.ofDim[Int](250)//number of times 
  </code></pre>
  
  <p>And the user has to enter ano1 and ano2 that are the years margin we want</p>
  
  <pre><code>val loop = new Breaks;
    for(i &lt;- 0 to 993){//copiamos
        loop.breakable{
          for(j&lt;- 0 to 249){
              if(artists2(j).contentEquals("NULL") &amp;&amp; artists(i)(1).toInt&gt;=ano1 &amp;&amp; artists(i)(1).toInt&lt;=ano2){
                artists2(j)=artists(i)(0)
                artists3(j)= 1
                loop.break;
              }else if(artists(i)(0).contentEquals(artists2(j)) &amp;&amp; artists(i)(1).toInt&gt;=ano1 &amp;&amp; artists(i)(1).toInt&lt;=ano2){
                artists3(j)= artists3(j)+1
                loop.break;
  
              }
  
          }
         }
    }
  
   println(artists2.mkString("\n")) 
   println(artists3.mkString(","))
  </code></pre>
  
  <p>For some reason my if doesnt work or j add itself 1 after entering in the if because every time is creating a new element in artists2 instead of adding it to artists3</p>
  
  <p>The output I get is artists3 filled with 1 because for some reason it never checks the other part of the if</p>