In our last post, we learned MongoDB Drop Collection example through command line.
This post explains how to drop or remove a complete collection in a Java Program.
drop() method is called on a DBCollection object to drop the entire collection along with the indexes associated.
dropIndexes() method removes all the indexes of the collection. This method is internally called from above method drop(). No need to explicitly call this.
Below example loads the collection "loans" and drops the collection