Birlasoft Interview Question

program to print occurrence of each character in a string

Interview Answer

Anonymous

May 18, 2019

Map result= new HashMap(); for(char ch:string.toCharArray()) { Integer I= result.get(ch); if(I == null) result.put(ch,1); else result.put(ch,I+1); }