Basic implementation on Java