Java version

tested with only 1 testcase