【发布时间】:2016-10-04 22:38:40
【问题描述】:
所以我的问题是我需要让用户输入string。然后他们将输入一个他们想要计算的字符。所以程序应该是count how many times the character他们输入的字符串会出现,这是我的问题。如果有人能给我一些有关如何执行此操作的信息,将不胜感激。
import java.util.Scanner;
public class LetterCounter {
public static void main(String[] args) {
Scanner keyboard= new Scanner(System.in);
System.out.println("please enter a word");//get the word from the user
String word= keyboard.nextLine();
System.out.println("Enter a character");//Ask the user to enter the character they wan counted in the string
String character= keyboard.nextLine();
}
}
【问题讨论】: