Q:

Returning a collection of interfaces

I have created the following interface
public interface ISolutionSpace {
  public boolean isFeasible();
  public boolean isSolution();
  public Set<ISolutionSpace> generateChildren();
}

However, in the implementation of ISolutionSpace in a class called EightQueenSolutionSpace, I am going to return a set of EightQueenSolutionSpace instances, like the following stub:
@Override
public Set<ISolutionSpace> generateChildren() {
  return new HashSet<EightQueenSolutionSpace>();
}

However this stub wont compile.  What changes do I need to make? 
EDIT: I tried 'HashSet' as well and had tried using the extends keyword.  However since 'ISolutionSpace' is an interface and EightQueenSolutionSpace is an implementation(and not a subclass) of 'ISolutionSpace', it is still not working. 

A:

Two possibilities:
@Override
public Set<?  extends ISolutionSpace> generateChildren() {
  return new HashSet<EightQueenSolutionSpace>();
}

Or
@Override
public Set<ISolutionSpace> generateChildren() {
  return new HashSet<ISolutionSpace>();
}

and simply add instances of EightQueenSolutionSpace to the set. 

A:

Mind you, inheritance and other object hierarchy features don't exactly work like expected in generics. 
But it's not your only problem : you try to return an ArrayList as an implementation of Set, which can't work ! 
Concerning the generics part, when you write Set<ISolutionSpace>, you say to the compiler you want a collection of instances of ISolutionSpace, but not of possible subclasses of ISolutionSpace.  To be allowed to use subclasses, you'll have to use ?  extends ISolutionSpace, which precisely says "accept any subclass of ISolutionSpace". 
So, to have a valid code, you'll have to change both your interface and your implementation.  
Your interface should become
public interface ISolutionSpace {
  public boolean isFeasible();
  public boolean isSolution();
  public Set<?  extends ISolutionSpace> generateChildren();
}

And your implementation
@Override
public Set<?  extends ISolutionSpace> generateChildren() {
  //for()
  return new HashSet<EightQueenSolutionSpace>();
}

A:

return new HashSet<ISolutionSpace>();

All the references in the HashSet can point to EightQueenSolutionSpace instances, but the generic type should be ISolutionSpace.