如果我有两个类常量:
List<String> workingList= new ArrayList<String>();
StringBuilder holder = new StringBuilder(50);
都驻留在里面,称之为类StringParser
和主要方法readStuff()
......
public class StringParser{
public void readStuff(){
//parsing logic and adding <String> elements to
//said workingList...
}//end of method readStuff
其次是我检查workingList
...的内容的方法
public String someReaderMethod()
{
int ind = 0;
for(int i = 0; i < workingList.size();i++)
{
if(workingList.get(i).contains(someExp))
{
workingList.remove(ind);
holder.append(workingList.get(i).toString());
}
else
{
++ind;
}
}
return holder.toString();
}
...鉴于该StringBuilder
持有人现在包含workingList
已删除的内容,有没有办法我可以将内容“传递”StringBuilder
给新的ArrayList
?