Java-version snake example