日期:2014-05-20 浏览次数:20621 次
public class Hello {
public static void main(String[] args) {
String [] a = {"ads", "awww", "fdgfdf", "fvdsfc", "hyjutfrdf"};
int[] frequence = new int[256];
for (String str : a) {
for (int i = 0; i < str.length(); ++i) {
frequence[str.charAt(i)]++;
}
}
for (int i = 0; i < frequence.length; ++i) {
if (frequence[i] != 0) {
System.out.printf("%s: %d\n", (char)i, frequence[i]);
}
}
}
}
a: 2
c: 1
d: 5
f: 7
g: 1
h: 1
j: 1
r: 1
s: 2
t: 1
u: 1
v: 1
w: 3
y: 1
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
public class StringCount
{
public static void main(String[] args)
{
String[] arr ={"ads","awww","fdgfdf","fdgfdf","fdgfdf"};