Bag implementation in java