0
美好的一天!在其他類中使用數組輸出
我有我返回報表名稱
System.out.println(bc[i].getDefaultName().getValue()
我想使用陣列輸出在其他類的陣列的方法,我需要怎麼聯繫方法outpud在我在其他類數組?
方法是:
public class ReoprtSearch {
public void executeTasks() {
PropEnum props[] = new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName};
BaseClass bc[] = null;
String searchPath = "//report";
//searchPath for folder - //folder, report - //report, folder and report - //folder | //report
try {
SearchPathMultipleObject spMulti = new SearchPathMultipleObject(searchPath);
bc = cmService.query(spMulti, props, new Sort[] {}, new QueryOptions());
} catch (Exception e) {
e.printStackTrace();
return;
}
if (bc != null) {
for (int i = 0; i < bc.length; i++) {
System.out.println(bc[i].getDefaultName().getValue();
}
}
}
}
陣列我想要把數組的樣子:
String [] folders =
我想這樣的:
ReoprtSearch search = new ReoprtSearch();
String [] folders = {search.executeTasks()};
返回我一個錯誤:無法轉換從無效到字符串
給我一個解釋,以瞭解如何我可以從其他類的方法輸出相關。
感謝
我不明白你的意見。我誤解了你的問題嗎? –
起初我不明白的意思。你展示瞭如何將輸出寫入數組。我會嘗試使用它來測試並找出 –
Alejandro,爲什麼在Eclipse 中爲''public String [] executeTasks()'行說我:'這個方法必須返回一個String []類型的結果' '結果;'最後? 我們使用'return results;'返回'string []'',因爲您將結果聲明爲字符串行'String results [] = new String [bc.length];' –