Java implementation of a chartrie