判断两个字符串包含元素是否相同

示例代码:

public static void main(String[] args) {
	String ss1 = "一二kk*escape(sSavedFileName*三四五六#七八;;九十''";
	String ss2 = "e(si一七k八escapleName;五;六SavedF'#二*k'三*四九十";
	char[] cc1 = ss1.toCharArray();
	char[] cc2 = ss2.toCharArray();
	Arrays.sort(cc1);
	Arrays.sort(cc2);
	ss1 = new String(cc1);
	ss2 = new String(cc2);
	System.out.println("ss1:"+ss1+"--ss2:"+ss2+ss1.equals(ss2));
}

 

运行结果:

ss1:#''(**;;FNSaaacdeeeeeikklmpssv一七三九二五八六十四
ss2:#''(**;;FNSaaacdeeeeeikklmpssv一七三九二五八六十四
结果:true

 

你可能感兴趣的:(字符串)