Implementation of various datastructures in java