欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

怎么判斷一個字符串有多少個字符串

錢艷冰2年前15瀏覽0評論

怎么判斷一個字符串有多少個字符串?

java根據以下判斷一個字符串中有幾個,

1、判斷長度"abc".length()

2、判斷某個字符有幾個 String a = "abbdfsads"; int n = a.length()-a.replaceAll("a", "").length(); System.out.println("字符串中字符a有"+n+"個"); /** * Returns true if and only if this string contains the specified * sequence of char values. * * @param s the sequence to search for * @return true if this string contains , false otherwise * @throws NullPointerException if is * @since 1.5 */ public boolean contains(CharSequence s) { return indexOf(s.toString()) > -1; } String str = "dfdf點點滴滴"; boolean b1 = str.contains("d"); boolean b2 = str.contains("點點滴滴");