I'm having trouble understanding a method. I have methods that I need to fill out, but I don't really understand the first one. How can Iterable be a return type and how is it used ? An example would be great..
@Override
public Iterable<ClientInterface> getNeighbours() {
return null;
}
@Override
public void addNeighbour(ClientInterface newNeighbour){
//TODO Implement me!
}
@Override
public void removeNeighbour(String clientID) {
//TODO Implement me!
}
It looks like your class should have an implementation of Iterable<ClientInterface>
as a class member, like ArrayList.
Let's use this as an example:
public class Bus {
private ArrayList<Person> riders;
... //constructors and other methods
public Iterable<Person> getRiders() {
return riders;
}
... //other methods
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With