public static void main(String[] args) {
List<String> deepCodes = new ArrayList<>();
deepCodes.add("212249.211848.682859.412401863dc446cf84d8e8c5341bd340");
deepCodes.add("212249.412401863dc446cf84d8e8c5341");
deepCodes.add("212249.222222.412401863dc446cf84d8e8c5341bd");
deepCodes.add("212249.211848.222222");
for(int i =0;i<deepCodes.size();i++){
String[] spli = deepCodes.get(i).split("\\.");
List<String> split = transferArrayToList(spli);
System.out.println(split);
for (int q=0;q<split.size();q++){
//System.out.println(split.get(q));
//System.out.println(split.get(q).length());
if (split.get(q).length()>10){
split.remove(q);
q--;//不减减不行,list元素在减少
}
}
System.out.println(split);
}
// deepCodes.add("212249.211848.682859");
// deepCodes.add("212249");
// deepCodes.add("212249.222222");
// deepCodes.add("212249.211848.222222");
}
private static List<String> transferArrayToList(String[] array){
List<String> transferedList = new ArrayList<>();
Arrays.stream(array).forEach(arr -> transferedList.add(arr));
return transferedList;
}
将List<String>每个元素的特定值进行修改