Can someone please guide me on how to achieve the below using Java 8. I don't know how to get that counter as the key
String str = "abcd";
Map<Integer,String> map = new HashMap<>();
String[] strings = str.split("");
int count =0;
for(String s:strings){
map.put(count++, s);// I want the counter as the key
}