library(R.utils)
capitalize(c("Hello world", "hello world", "hello World", "test cAse"))
[1] "Hello world" "Hello world" "Hello World" "Test cAse"
我想修改动物ArrayList中的元素。喜欢这个"亚洲大象" 不使用animals.replace()方法。
答案 0 :(得分:4)
在你的地方,我只是制作动物类,然后是动物的ArrayList。但如果你不想,那么你可以这样做:
animals.set(index, element);
其中index是动物编号,元素是新名称。另一个选项是删除旧动物名称并添加新动物名称,例如:
animals.remove(o);
animals.add(e);
其中o是旧名称,e是新名称。