Implementation of data structures in Java