锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
聽聽聽聽聽聽聽 瀹炵幇浠g爜濡備笅:
聽聽public class TestChineseChar {
聽聽public static void main(String[] args) {
聽聽TestChineseChar t = new TestChineseChar();
聽聽t.getChineseChar();
聽}
聽public void getChineseChar() {
聽聽String str = "adf鎴慾k鐖眘df鑾兘鍔﹍kka";
聽聽StringBuffer sb = new StringBuffer();
聽聽String tempStr;
聽聽int count = 0;
聽聽for (int i = 0; i < str.length(); i++) {
聽聽聽tempStr = String.valueOf(str.charAt(i));
聽聽聽if (tempStr.getBytes().length == 2) {
聽聽聽聽sb.append(tempStr);
聽聽聽聽count++;
聽聽聽}
聽聽}
聽聽System.out.println("the count of chinese characters in the String is :"
聽聽聽聽+ count);
聽聽System.out.println(sb.toString());
聽}
}