-1
public static void main(String[] args) {
ReadAuthor ReadAuth = new ReadAuthor();
ReadCommands readCom = new ReadCommands(); }
建立在ReadARticles類的對象我有創造的文章ArrayList的的方法。困惑達到另一類
public class ReadArticles {
public ArrayList<Article> articleList = new ArrayList<Article>();
while(i=0;i<line number;,++){
public void readDaFile(){
articleList.add(new Article(ID,name,publisherName,publishYear));
}
從ReadCommands
類,我稱之爲ReadArt.readDaFile
(讀取,但也創造了數組列表)。
public class ReadCommands {
ReadArticles readArt = new ReadArticles();
public void readDaFile(){
readArt.tryOpeningOrDieTrying(filename);
readArt.readDaFile(); }
我的問題是,從主,我可以達到articlelist
;
System.out.println(readCom.readArt.articleList.get(20).getPublisherName());
或
System.out.println(readCom.getArticleList().size());
但我不能從readAuthor
類(閱讀作者和爲他們創造的ArrayList創建另一個類到達文章列表。
我甚至在嘗試創建getter
爲ArticleList
這兩個ReadCommands
和ReadArticles
類,以確保但getters
只適用於main。我的目標是查看來自ReadAuthor類的articleList。