【发布时间】:2010-12-31 16:15:53
【问题描述】:
我来自 php,所以我想学习 java。 在 for 循环中的 php 中,如果我想创建一个数组,我只是这样做
$items = $this->getItems();
for($i=0;$i<count($items);$i++)
{
$myarrayitems[$i] = $items[$i];
}
return $myarrayitems;
但是在java中我得到了arrayoutofexponsion之类的。
这是我正在尝试的代码
public String[] getItems(String url) throws Exception
{
URL rss = new URL(url);
Feed feed = FeedParser.parse(rss);
int items = feed.getItemCount();
int a = 0;
for (int i = 0; i < items; i++)
{
FeedItem item = feed.getItem(i);
String title[i] = item.getTitle();
}
return title;
}
如何将标题作为数组返回并制作一个 var_dump?
【问题讨论】: