fixing bug in example java code