i written a program to count each alphabet appears in the given string and i got output but already counted alphabet is repeating again i think my doubt is not much clarity i will provide my code below and output code: package mithun; public class ForLoop { public static void main(String[] args) { String s1="mithunmithun"; int count=0; for(int i=0;i<=s1.length()-1;i++) { char c1=s1.charAt(i); for(int j=0;j<=s1.length()-1;j++) { if(s1.charAt(i)==s1.charAt(j)) { count=count+1; } } System.out.println(s1.charAt(i)+"-"+count); count=0; } } } output: m-2 i-2 t-2 h-2 u-2 n-2 m-2 i-2 t-2 h-2 u-2 n-2 expected output is m-2 i-2 t-2 h-2 u-2 n-2 | 0 |