标签:ar os for sp 数据 on bs amp new
@org.junit.Test
public void tt (){
System.out.println(ifresultStr("1,2,3,4,5,6,7,8,9"));
}
public static String ifresultStr(String id){
String numo="0";
if(id!=null&&id!=""){
String ids[] = id.split(",");
String resultStr = "";
for (int i = 0; i < ids.length; i++) {
if (ids[i].equals("1")) {
resultStr += "1,";
} else if (ids[i].equals("2")) {
resultStr += "2,";
} else if (ids[i].equals("3")) {
resultStr += "2,";
} else if (ids[i].equals("4")) {
resultStr += "2,";
} else if (ids[i].equals("5")) {
resultStr += "2,";
} else if (ids[i].equals("6")) {
resultStr += "2,";
} else if (ids[i].equals("7")) {
resultStr += "3,";
} else if (ids[i].equals("8")) {
resultStr += "3,";
} else if (ids[i].equals("9")) {
resultStr += "3,";
} else if (ids[i].equals("10")) {
resultStr += "3,";
} else if (ids[i].equals("11")) {
resultStr += "4,";
} else if (ids[i].equals("12")) {
resultStr += "4,";
} else if (ids[i].equals("13")) {
resultStr += "5,";
} else if (ids[i].equals("14")) {
resultStr += "5,";
}
}
//去除重复数字 例如 1,2,2,2,2,2,3,3,3 去除完 结果== 1,2,3
String[] array = resultStr.split(",");
StringBuilder sb = new StringBuilder();
for (String str : array) {
if(sb.indexOf(str) != -1){
continue;
}
sb.append(str).append(",");
}
String newStr = sb.toString().substring(0,sb.length() - 1);
return newStr ;
}
return numo;
}
标签:ar os for sp 数据 on bs amp new
原文地址:http://www.cnblogs.com/yy123/p/4078096.html