You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virtual-patient/virtual-patient-model/src/main/java/com/supervision/util/StringChartUtil.java

25 lines
526 B
Java

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.supervision.util;
import java.util.Arrays;
/**
* @Authorlongbao
* @Date2024/11/1 13:52
* @Description:
*/
public class StringChartUtil {
/**
* 字符串中某个字符出现的次数
* @param str 源字符串
* @param targetChar 查找字符
* @return 出现次数
*/
public static int countChar(String str, char targetChar) {
return (int) Arrays.stream(str.split(""))
.filter(s -> s.charAt(0) == targetChar)
.count();
}
}