Count letters in a string Java

前端 未结 5 1342
一向
一向 2020-12-10 09:33

I\'m doing an assignment where I\'ll have to code a program to read in a string from user and print out the letters in the string with number of occurrences. E.g. \"Hell

5条回答
  •  暖寄归人
    2020-12-10 10:01

    import java.io.*;

    public class CharCount {

    public static void main(String[] args) throws IOException
    {
        int i,j=0,repeat=0;
        String output="",input;
        char c=' ';
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        System.out.println("enter name ");
        input=br.readLine();
        System.out.println("entered String ->\""+input+"\"");
        input=input.toLowerCase();
    
        for(i=0;i\""+output+"\"");
    
        int count[]=new int[output.length()];
        for(i=0;i

    }

提交回复
热议问题