Java Implementation