-3
比较集合中的元素(不知道索引,因此可以使用contains/equals来比较字符串值),检查是否存在,然后必须为该字符串值添加一些字符(将从其他地方拾取),然后将其添加回集合中作为最后一个元素。
示例方案:
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
你有没有尝试什么吗? – 2015-02-09 23:13:39
Collections.binarySearch(xyz,“jsh”)将返回索引。 – 2015-02-09 23:13:41