判断连个字符串是否相等忽略其字符顺序

           String s1 = "dda";
		String s2 = "add";

		byte[] sa1 = s1.getBytes();
		byte[] sa2 = s2.getBytes();
		Arrays.sort(sa1);
		Arrays.sort(sa2);
		String ss1 = new String(sa1);
		String ss2 = new String(sa2);
		if (ss1.equals(ss2)) {
			System.out.println("equal");
		} else {
			System.out.println("not equal");
		}


你可能感兴趣的:(判断连个字符串是否相等忽略其字符顺序)