Java Implementaion