### Find out count of all characters in string using HashMap (including special characters) in java

In this core java programming tutorial we will write a program to Find out count of all characters in string using HashMap (including special characters) in java.

Write a program to find out Find out count of all characters in string using hashMap, special characters also must be counted.

Example>
inputString is : This is it
Output is : T=1 h=1 i=3 s=2  =2 t=1

Must read: Fibonacci series using recursion in java.

Full Program/SourceCode/ Example to Find out count of all characters in string using HashMap (including special characters) in java >
 import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; /** Copyright (c), AnkitMittal www.JavaMadeSoEasy.com */ public class  CharacterCountInStringUsingHashMapExample {       public static void main(String[] args) {       String inputString="This is it";        System.out.println("inputString is : "+inputString);        System.out.print("Output is : ");        characterCount(inputString);    }       /**     * Method calculates count of all characters in inputString.     */    public static void characterCount(String inputString){       Map map=new LinkedHashMap(); //LinkedHashMap used so that we could maintain insertion order.       char[] inputAr=inputString.toCharArray();             for(int i=0;i charIterator=map.keySet().iterator();       while(charIterator.hasNext()){           char ch=charIterator.next();           System.out.print(ch+"="+map.get(ch)+" ");       }          }    } /*OUTPUT inputString is : This is it Output is :T=1 h=1 i=3 s=2  =2 t=1 */

So in this core java programming tutorial we learned how to write a program to Find out count of all characters in string using HashMap (including special characters) in java.

Having any doubt? or you you liked the tutorial! Please comment in below section.