我有一个“do - while”循环,其中包含 5000 个数字,在每次运行循环期间应该将其添加到数组中,如下所示:
问题是每次执行循环时,数字都会被覆盖,一旦循环结束,数组中只有最后一次运行的数据。
我使用这段代码:
long cursor = -1;
long[] fArray = new long[100000]; // more than enough space in array
IDs ids = twitter.getFollowersIDs(name, cursor); // start with first page of 5000 numbers
do
{
ids = twitter.getFollowersIDs(name, cursor);
fArray = twitter.getFollowersIDs(name, cursor).getIDs(); // this gets Array with 5000 numbers every time until "empty"
cursor = ids.getNextCursor(); // jump to next array with 5000 new numbers
} while (ids.hasNext());