2013-02-06 3 views
0

어떻게 문자를 다음과 같이 쓸 수 있습니까? 그것은 내가 Set과 String을 비교하려고 노력하고 있으며 for for loop가 맘에 들지 않는다고 생각합니다. & &과 같은 논리식을 작성하는 방법은 무엇입니까? 감사합니다.Scriptella : 컬렉션 및 각 루프에 사용

<connection id="java" driver="scriptella.driver.janino.Driver"/> 

<script connection-id="java> 

//some code 

if(finalOrderCounter &lt; numberOfEntries){ 
    Set &lt;String> set = new HashSet &lt;String>(); 
    for(int i = 0; i &lt; fieldNames.length; i++){ 
     set.add(fieldNames[i]); 
    } 
    for(int i = 0; i &lt; fieldNamesFromXML.length; i++){ 
     set.remove(fieldNamesFromXML[i]); 
    } 
    String exception = ""; 
    for(String element:set) 
     exception += element +"\n"; 
    throw new IOException("Field(s)\n" + exception + "do(es) not exits in the source database"); 
} 

답변

0

은 아마 당신은 루프 구문 '에 대한'는 "고전"을 시도 할 수 있습니다?

StringBuffer exception = new StringBuffer(); 
for (int i = 0; i &lt; set.size(); ++i) { 
    String element = (String) set.get(i); 
    exception.append(element); 
    exception.append("\n"); 
} 
throw new IOException("Field(s)\n" + exception.toString() + "do(es) not exits in the source database"); 

그런데 어떤 오류가 발생합니까?