I am trying to convert following code into Java 8::

```
String s = "12345";
Map<Character,Integer> map = new HashMap<Character,Integer>();
for (int i = 0; i < 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);
 }
}

```

I tried and found following way to iterate:

```
IntStream.rangeClosed(0, s.length).foreach(d -> {
      //all statements from char to map.put
}) ;

```

I am not sure whether this is correct way to do it.