public class List1 {
public static void main(String[] args) {
String s = "abc nnn ooo/xzsxc bs";
System.out.println("原字符串:"+ s + " ");
//把s字符串变成ss数组,然后根据空格截取字符串
String[] ss = s.split(" ");
//把数组放进list里面,进行遍历,把数组里的每个元素都单独取出来
List<String> a = new ArrayList<>();
for (int i = 0; i < ss.length;i++){
a.add(ss[i]);
}
System.out.println("更新后的字符串:");
//进行第二次遍历把每个元素的前后都加上/
for (int i = 0;i < ss.length;i++){
ss[i] = ss[i].replaceAll(ss[i],"/"+ss[i]+"/");
System.out.println(ss[i]);
}
}
}