1、 统计在一个输入字符串中各个不同字符出现的频度。
import java.util.*;
public class s5_1 {
public static void main(String []args)
{
String s = "hello, how are you, fine, thank
you";
Map<Character, Integer> mapchar = new
HashMap();
for(int i=0; i<s.length(); i++)
{
char ch = s.charAt(i);
Integer obj = mapchar.get(new
Character(ch));
if(obj == null)
{
mapchar.put(new Character(ch), new
Integer(1));
}
else
{
obj ++;
mapchar.put(new Character(ch),
评论0