2012-11-29 3 views
2

다음과 같은 방법으로 마지막 항목을 반환하지만 어떻게 주석 목록을 보낼 수 있습니까?목록의 반환 방법

내가 루프

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

정확하게 무엇을하려하고 있으며 무엇이 문제입니까? –

+6

'annotations.addAll' – Alex

답변

3

에서 모든 주석 목록을 반환하려는 당신은 모든 Annotation 함께이야, 당신은 새로운 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; 
} 
+0

EList를 붙이려고했을 때 annotations = new EList (); 오류가있어 유형을 인스턴스화 할 수 없습니다. EList (); , 어떤 생각? –

+0

자바 6을 사용하고 있습니다 ... –

+0

Btw 나는 import import org.eclipse.emf.common.util.EList에 있음을 발견했습니다. 그러나 문제는 여전히 존재합니다. –

관련 문제