mercredi 3 juin 2015

Can a java method return value depending upon condition?

Say, I have 2 interfaces xx and yy

I want to return the instance of these interfaces from a single method depending upon condition.

public xxx testMethod(){

  //some condition
  return instanceof xx;

  // other condition
  return instanceof yy;

}

Is there any design pattern for this kind of scenario?

Aucun commentaire:

Enregistrer un commentaire