in Java code example fix variable name for consistency

--rebased-from #487 partially to fix a mistake in #478, cc: @ctrueden