Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6716087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:41:28+00:00 2026-05-26T08:41:28+00:00

I have been developing an implementation of the neighbourhood algorithm in Java for a

  • 0

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.

I have been getting the error
”

incompatible types
found   : void
required: java.util.List<VoronoiPoint>

” 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 List<VoronoiPoint>. If anybody can explain to me what is going on it would be much appreciated!

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<VoronoiPoint> thelist = VoronoiList.startlist(ns,n);
    //System.out.println(thelist);
    //System.out.println(thelist.get(1).misfit);
    for (Integer i=0 ; i<thelist.size() ; i++)
    {
      thelist.get(i).setmisfit();
    }
    List<VoronoiPoint> 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 < point1.length; i++)
    {
      distance = distance + Math.pow((point1[i]-point2[i]),2);
    }
  return Math.sqrt(distance);
  }
}

The other classes I used are here:
The VoronoiList class:

import java.util.*;

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

The VoronoiPoint class:

import java.util.Random;

public class VoronoiPoint implements Comparable<VoronoiPoint>
{
  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 < 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 < 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<b.misfit) return -1;
    else if (this.misfit==b.misfit) return 0;
    return 1;
  }
}

And the parameter boundaries class:

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<n; i++)
    {
      boundaries[2*i] = -1.0;
      boundaries[2*i+1] = 1.0;
    }
  }
  public Double getboundaries(Integer i)
  {
    return boundaries[i];
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:41:28+00:00Added an answer on May 26, 2026 at 8:41 am

    Collections.sort(..) sorts the original list. It doesn’t return a new list. (Its return type is void)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been developing with Java for several years and last six months I
I have been developing a project and in this project i have designed my
I have been developing applications based on C# (.net) and Java (J2EE) for the
I am a new to developing for Android and have been reading up and
I have been developing a windows form based project in visual basic .NET, moving
I have been developing my web-app using JPA 2.0 implementation EclipseLink 2.2.0. I finally
People have been developing own solutions to the following problems: Consistent messaging frameworks for
I have been developing websites for a couple of years now and I almost
I have been developing a C# windows form application in XP. It all works
I have been developing in asp.net since its existence (also classic asp before that)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.