我不确定如何计算每个字母的出现次数。有人可以指出我这样做的正确方向吗,谢谢:)
if(icanreadstrings.equals ("start")){
String strten = Console.readLine("Enter 10 letters (no spaces,commas between each letter and no numbers): "); // Asks the user to enter 10 letters which is then saved as a string "strten".
Console.println(strten);// Prints out whatever the user entered.
if(strten.matches("[a-zA-Z]+") && strten.length() == 10){ // if whatever the user enters is letters (not numbers) and if it matches to the length, which is 10.
Console.println("There are " + strten.length() + " letters that you've wrote."); // lets the user continue if they've wrote 10 letters, yes 10!
}else{
Console.println("There are more than or less than 10 letters that you've wrote or you have numbers in your list of letters. Please rewrite 10 different LETTERS for this program to continue."); // Checks to see if you wrote more than 10 letters if you did then it prompts a message and the user can't continue until he writes 10 letters.
}
}