String a = “abcd,efg”;
String b = “)(*&^%$#@![]{},.//;:’? <>”;
要求是判断String a 里有没有哪个字符在String b里出现 ,效率越高越好
/** * 查找某些字符是否在另一个字符串里出现 * * @author Java人(java2000.net) */ public class Test { /** * @param args */ public static void main(String[] args) { String a = “abcd,efg”; String b = “)(*&^%$#@![]{},.///;:’? <>”; byte[] bb = new byte[256]; char[] cs = b.toCharArray(); for (char c : cs) { bb[c] = 1; } cs = a.toCharArray(); for (char c : cs) { if (bb[c] == 1) { System.out.println(c); } } } }