java example improvement