practice histogram function in java