I have this problem, I'd like to return a list of interface and implementation class only after the if
block.
public interface Lotto { }
public class LottoImplSecond implements Lotto { }
public class LottoImplFirst implements Lotto { }
public class MyClass {
public List<Lotto> getLotto(Integer number){
if(number==1) List<Lotto> listaLotto=new ArrayList<LottoImplFirst>();
else if(number==2) List<Lotto> listaLotto=new ArrayList<LottoImplSecond>();
return listaLotto;
}