count of words in array

    0

    0

    package example
    object findnumberofwords extends App {
      var array1 = Array("rabindra","jaiswal","rabindra")
      var map1 = collection.mutable.Map[String,Int] ()
      var count1 = 1
    
      for (i <- array1){
      if(!map1.contains(i)) {
        map1 += (i -> count1)
      } else map1(i) +=1
    
      }
      println(map1)
    }
    
    package example
    object findnumberofwords extends App {
      var array1 = Array("rabindra","jaiswal","rabindra")
      var map1 = collection.mutable.Map[String,Int] ()
      var count1 = 1
    
      for (i <- array1){
      if(!map1.contains(i)) {
        map1 += (i -> count1)
      } else { map1(i) +=1 }
    
      }
      println(map1)
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.