Collections.sort compile error - incompatible types
<p>I have been developing an implementation of the neighbourhood algorithm in Java for a physics project I am working on. I'm brand new to Java so I apologize for any idiocy that results.</p>

<p>I have been getting the error 
''</p>

<pre><code>incompatible types
found   : void
required: java.util.List&lt;VoronoiPoint&gt;
</code></pre>

<p>'' on line 22 from the Java compiler in attempting to compile the program shown below. I cannot figure out why the variable ''thelist'' somehow turns into a void when I declared it to be of type <code>List&lt;VoronoiPoint&gt;</code>. If anybody can explain to me what is going on it would be much appreciated!</p>

<pre class="lang-java prettyprint-override"><code>import java.lang.Double;
import java.util.*;


public class VoronoiTiling 
{


  public static void main(String args[]) 
  {
    Integer n = 10; //Number of dimensions of model parameter space
    Integer ns = 20; //Number of points per iteration
    Integer nr = 4; //Number of cells to populate
    Integer iterations = 5; //Number of iterations
    List&lt;VoronoiPoint&gt; thelist = VoronoiList.startlist(ns,n);
    //System.out.println(thelist);
    //System.out.println(thelist.get(1).misfit);
    for (Integer i=0 ; i&lt;thelist.size() ; i++)
    {
      thelist.get(i).setmisfit();
    }
    List&lt;VoronoiPoint&gt; orderedlist = Collections.sort(thelist);
    Double distance = EuclidianDistance((thelist.get(1)).location,(thelist.get(2)).location);
    System.out.println(distance);
  }

  public static Double EuclidianDistance(Double[] point1, Double[] point2)
  {
    Double distance=0.0;
    for (int i = 0; i &lt; point1.length; i++)
    {
      distance = distance + Math.pow((point1[i]-point2[i]),2);
    }
  return Math.sqrt(distance);
  }
}
</code></pre>

<p>The other classes I used are here:
The VoronoiList class:</p>

<pre class="lang-java prettyprint-override"><code>import java.util.*;

public class VoronoiList
{
  public static List&lt;VoronoiPoint&gt; startlist(Integer ns, Integer n)
  {
    List&lt;VoronoiPoint&gt; thestartlist = new ArrayList&lt;VoronoiPoint&gt;();
    for (int i = 0; i &lt; ns; i++)
    {
      thestartlist.add(new VoronoiPoint(0.,n));
    }
    return thestartlist;
  }
}
</code></pre>

<p>The VoronoiPoint class:</p>

<pre class="lang-java prettyprint-override"><code>import java.util.Random;

public class VoronoiPoint implements Comparable&lt;VoronoiPoint&gt;
{
  Double[] location;
  private Random generator = new Random();
  Double misfit = -1.;

  //***************************************************************
  public VoronoiPoint(Double misfit, Integer n)
  {
    location = new Double[n];
    ParameterBoundaries boundaries = new ParameterBoundaries(n);
    for(int i = 0; i &lt; n; i++)
    {
      location[i] = boundaries.getboundaries(2*i)+2*generator.nextDouble();
    }
  }
  //***************************************************************
  //public Double[] getlocation()
  //{
    //return location;
  //}
  public void setlocationi(Integer i, Double j)
  {
    location[i] = j;
  }

  //***************************************************************

  public void setmisfit()
  {
    Integer n = location.length;
    Double tempmisfit = 0.0;
    for(Integer i = 0; i &lt; n; i++)
    {
      tempmisfit = tempmisfit + Math.pow((location[i]),2);
    }
    misfit = Math.sqrt(tempmisfit); // Temporarily just distance to centre
  }

  //public Double getmisfit()
  //{
    //return misfit;
  //}
  public int compareTo(VoronoiPoint b)
  {
    if (this.misfit&lt;b.misfit) return -1;
    else if (this.misfit==b.misfit) return 0;
    return 1;
  }
}
</code></pre>

<p>And the parameter boundaries class:</p>

<pre class="lang-java prettyprint-override"><code>public class ParameterBoundaries
{
  private Double[] boundaries; /*Set to 2n where n is dimensions of parameter space, 
   * it just makes it easier*/
  public ParameterBoundaries(Integer n)
  {
    boundaries = new Double[2*n];
    for(Integer i = 0; i&lt;n; i++)
    {
      boundaries[2*i] = -1.0;
      boundaries[2*i+1] = 1.0;
    }
  }
  public Double getboundaries(Integer i)
  {
    return boundaries[i];
  }
}
</code></pre>
