Java将LinkedList插入现有的LinkedList

时间:2016-02-25 10:38:22

标签: java insert

我正在编写一个读取XML文件的类,XML使用'sax'类进行解析。在我的XML文件中,我创建了'for'标签和'宏',它们允许在XML中编写循环,例如:

    <for start="1" end="10" iterator="row" increment="1">
      <text>This is line $row$</text>
    </for>

文本$ row $在运行时被替换为迭代器的值。处理for循环时,它会生成一个名为“row”的宏,用于处理循环内容。这很有效。

我的XML解析器生成一个标签类的LinkedList,其中每个标签都包含自己的子标签LinkedList。

'for'循环是一个标记,当'for'循环被处理时,它会生成一个LinkedList结果。我想用LinkedList替换LinkedList中的原始'for'标记。

1 个答案:

答案 0 :(得分:1)

解决方案:

在原始链接列表中,找到要删除的对象:

    intForIdx = llChildren.indexOf(mobjCurrent);

删除原始对象:

    llChildren.remove(intForIdx);

在同一位置插入新的链接列表:

    llChildren.addAll(intForIdx, llResults);
相关问题