java中如何把两个字符串中求重复的字符串取出来

2024-11-17 22:16:42
推荐回答(1个)
回答1:

String a ="sdfasdfasdf";
String b ="asdfhearhmykky";

for(char i :a.toCharArray() ){
if(b.indexOf(i)!=-1){
System.out.print(i);
}
}