public static void compare(String s1,String s2){
byte[]b1 = s1.getBytes();
byte[]b2 = s2.getBytes();
Arrays.sort(b1);
Arrays.sort(b2);
s1 = new String(b1);
s2 = new String(b2);
if(s1.equals(s2)){
System.out.println("equal");
}else {
System.out.println("not equal");
}
}
判断两个字符串是否由相同的字符组成
最新推荐文章于 2019-01-29 21:13:16 发布