java exercise implementation of k-means clustering algorithm