我有這樣的代碼,它工作正常:動態對象添加到陣列
News news_data[] = new News[] {
new News("1","news 1","this is news 1"),
new News("2","news 2","this is news 2"),
new News("2","news 1","this is news 2"),
};
在這段代碼中我添加3個新的對象,但我必須動態地添加他們在循環中。我怎樣才能做到這一點?事實上,我不明白這個數組結構。請解釋這段代碼給我,如果你可以把它簡單
我試過,但它不工作:
News news_data[];
for(i=1;i<3;i++){
news_data=new News[] {
new News("1","news 1","this is news 1"),
new News("2","news 2","this is news 2"),
new News("2","news 1","this is news 2"),
};
}