Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class StringHandling
- {
- public static void main(String args[])
- {
- Scanner sc=new Scanner(System.in);
- String s=sc.nextLine();
- int i,j,cnt=0;
- char ch;
- for(i=0;i<s.length();i++)
- {
- ch=s.charAt(i);
- //if character is already
- // present then skip
- if(s.indexOf(ch)<i)
- continue;
- for(j=(i+1);j<s.length();j++)
- {
- if(s.charAt(j)==ch)
- cnt++;
- }
- System.out.println(ch+": "+cnt);
- //reset count to 0
- cnt=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment