public void nextIteration(double[][] means){
  this.means=means;
  changed=false;
  final int k=means.length;
  final int dim=means[0].length;
  centroids=new double[k][dim];
  sizes=new int[k];
  Arrays.fill(varsum,0.);
}

public void nextIteration ( double [ ] [ ] means ) { this . means = means ; changed = false ; final int k = means . length ; final int dim = means [ 0 ] . length ; centroids = new double [ k ] [ dim ] ; sizes = new int [ k ] ; Arrays . fill ( varsum , 0. ) ; }
initialize for a new iteration .
