满意答案
oicq...
2013.07.10
采纳率:40% 等级:13
已帮助:13836人
import java.util.Arrays;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println(func("silent", "listen"));
System.out.println(func("", ""));
}
public static boolean func(String str1, String str2) {
char[] arr1 = str1.toCharArray();
char[] arr2 = str2.toCharArray();
Arrays.sort(arr1);
Arrays.sort(arr2);
for(int i = 0; i < arr1.length; i++) {
if(arr1[i] != arr2[i]) {
return false;
}
}
return true;
}
}
01分享举报