2

我有以下方法,现在返回最后一个条目,但是如何发送注释列表?

我想从循环中返回所有注释列表

public EList<Annotation> getAnnotation()
{
  EList<Annotation> annotations = null;
  for (Sc currSc : sche)
  {
    for (EntityS entitys : ent)
    {
      // Get annotation
      annotations = entitys.getAnnotations();
    }
  }
  return annotations;
}
4

1 回答 1

3

如果你想把所有的Annotations 放在一起,你需要创建一个全新的EList,然后将它们全部添加,即

public EList<Annotation> getAnnotation()
{
  // Create the new list that will hold ALL the annotations
  EList<Annotation> annotations = new BasicEList<Annotation>();
  for (Sc currSc : sche)
  {
    for (EntityS entitys : ent)
    {
      // Get annotation
      annotations.addAll(entitys.getAnnotations());
    }
  }
  return annotations;
}
于 2012-11-29T14:36:43.287 回答