在arraylist中为每个字符串添加一个char

use*_*850 1 java arrays string

例如

String temp = "welcome,to,the,world,of,j2ee";
Run Code Online (Sandbox Code Playgroud)

将其转换为arraylist

ArrayList al= new ArrayList(temp.split(","));
Run Code Online (Sandbox Code Playgroud)

这是作为arraylist的内容 {"welcome","to","the","world","j2ee"}

我的要求是在每个字符串的末尾添加"^ d"

对于前 {"welcome^d","to^d","the^d","world^d","j2ee^d"}

sad*_*dhu 5

试试这个:

List<String> al= Arrays.asList((temp.replaceAll(",", "^d,") + "^d").split(","));
Run Code Online (Sandbox Code Playgroud)