Java implementation of a single-linked chain data structure