gpt4 book ai didi

java - 计算给定字母在Java中出现的句子

转载 作者:行者123 更新时间:2023-11-29 04:14:06 26 4
gpt4 key购买 nike

<分区>

String sentence = JOptionPane.showInputDialog (null, "Write a sentence.");    
String letter = JOptionPane.showInputDialog(null, "Write a letter");

while (true) {

if (letter.equals("Stop"))
System.exit(0);
//to calculate number of specific character
else {
int countLetter = 0;
int L = letter.length();
for (int i = 0; i < L; i++) {
if ((letter.charAt(i) = .....))
countLetter++;
}
}
}

是否可以替换点以使程序计算给定字母在第一个字符串中所写的句子中出现了多少次?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com