compiler giving NullPointerException error, dont know why. please help?
public List<DBObject> findByDateDescending(int limit) {
List<DBObject> posts = null;
// XXX HW 3.2, Work Here
// Return a list of DBObjects, each one a post from the posts collection
DBCursor cur=postsCollection.find().sort(new BasicDBObject("date",-1)).limit(limit);
while(cur.hasNext()){
/*==>> error */ posts.add(cur.next());
}//end while
return posts;
}