Data Structure Implementation in java