如何实现:
比较集合中的元素(不知道索引,因此可以使用包含/等于来比较字符串值),检查是否存在,然后必须向该字符串值中添加一些字符(将从其他位置提取)将其添加回集合中,成为最后一个元素。
示例方案:
xyz<Collection> contains these values:
"abc"
"hgj"
"jsh"
"yjk"
if (xyz.contains("jsh")){
then concat "jsh" + " " + randomOtherStuff
And put it back in the collection to be last element so when printed the order is
"abc"
"hgj"
"yjk"
"jsh + " " + randomOtherStuff"
}
谢谢您的所有帮助,提前:D
if (collection.contains("jsh")) {
collection.remove("jsh"); // remove it, so it can be re-added to the end
collection.add("jsh " + "asdfgdfgsdfhsjdfh"); // add the new string + some random stuff to the end of the list
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句