title: How to write String Iteration with Map Put operations in Java 8?
body: <p>I am trying to convert following code into Java 8::</p>
  
  <pre><code>String s = "12345";
  Map&lt;Character,Integer&gt; map = new HashMap&lt;Character,Integer&gt;();
  for (int i = 0; i &lt; s.length(); i++) {
   char c = s.charAt(i);
   if (map.containsKey(c)) {
     int cnt = map.get(c);
     map.put(c, ++cnt);
   } else {
     map.put(c, 1);
   }
  }
  </code></pre>
  
  <p>I tried and found following way to iterate:</p>
  
  <pre><code>IntStream.rangeClosed(0, s.length).foreach(d -&gt; {
        //all statements from char to map.put
  }) ;
  </code></pre>
  
  <p>I am not sure whether this is correct way to do it.</p>