我有以下代码:
public void parseAttribs(String attribs){
//attribs is a comma separated list
//we are making a List from attribs by splitting the string at the commas
List<String> attributes = Arrays.asList(attribs.split("\\s*,\\s*"));
//when I try to add an element to the attributes List if fails
attributes.add("an element");
我发现这个Unable to add a String to an ArrayList: "misplaced construct(s)"并试图创建一个子类,但我也必须将 List 传递给子类,但它仍然不起作用。
任何人都可以对此有所了解吗?
非常感谢