Implementation of Basic data structure in java