java code (first commit)