Coding data structure with java