日期:2014-05-20 浏览次数:20961 次
public static String[] filterKey(String key,String[] jlKeyFrs){ String resStr = ""; if(key.length()==2){ for(int j=0;j<jlKeyFrs.length;j++){ if(!jlKeyFrs[j].startsWith(key)){ resStr+=jlKeyFrs[j]+","; } } }else{ for(int j=0;j<jlKeyFrs.length;j++){ if(jlKeyFrs[j]!=key){ resStr+=jlKeyFrs[j]+","; } } } if(resStr.length()>1){ if(resStr.endsWith(",")){ resStr=resStr.substring(0, resStr.length()-1); } } return resStr.split(","); } public static String[] callBack(String[] wllKeys,String[] jlKeyFrs){ String[] filterResults = null; if(wllKeys.length == 1){ filterResults = filterKey(wllKeys[0],jlKeyFrs); }else{ String[] temps = filterKey(wllKeys[0],jlKeyFrs); String[] tempWllKeys = new String[wllKeys.length - 1]; for(int k=0;k<tempWllKeys.length;k++){ tempWllKeys[k] = wllKeys[k+1]; } callBack(tempWllKeys,temps); } return filterResults; } public static void main(String[] args) { String[] arr = callBack(new String[]{"3604","3603"},new String[]{"3604","3605","3603"}); for(int i = 0;i<arr.length;i++){ System.out.println(arr[i]); } }
public static String[] callBack(String[] wllKeys,String[] jlKeyFrs){ String[] filterResults = null; if(wllKeys.length == 1){ filterResults = filterKey(wllKeys[0],jlKeyFrs); }else{ // 你所传递的是length为2,但在else里没有返回值。 // filterKey方法中第一个参数既然是一个字符串,if(key.length()==2)你要判断它的长度为2位? 如 05,而不是3604 4位? String[] temps = filterKey(wllKeys[0],jlKeyFrs); String[] tempWllKeys = new String[wllKeys.length - 1]; for(int k=0;k<tempWllKeys.length;k++){ tempWllKeys[k] = wllKeys[k+1]; } callBack(tempWllKeys,temps); } return filterResults;