Returnimng collection of interfaces

Posted by apoorv020 on Stack Overflow See other posts from Stack Overflow or by apoorv020
Published on 2011-01-17T10:36:51Z Indexed on 2011/01/17 10:53 UTC
Read the original article Hit count: 205

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about java

Related posts about homework