Witam. Mam następujący problem.
Tworzę
public interface ILiczba
{
public int metoda();
}
Lub
abstract public class Liczba
{
abstract public int metoda();
}
Następnie implements / extends użyć można zamiennie z odpowiednią nazwą np.:
public class Jeden extends Liczba
{
public int metoda()
{
}
}
public class Dwa extends Liczba
{
public int metoda()
{
}
}
public class Kalkulator
{
public int metodaX(ArrayList<Liczba>)
{
A.metoda() (OPERACJA) B.metoda()
}
}
I próbuje wywołać jako
Kalkulator K = new Kalkulator().
K.metodaX(ArrayList<Dwa>);
Dostaję błąd o niekompatybilności typów... W czym tkwi problem? Czy parametry interface'u lub klasy nie powinny zostać przekazane?