int[]
(массив int
) не является ArrayList<Integer>
(List
из Integer
, в частности ArrayList
).
Вы бы хотели использовать List
:
List<Integer> list = new ArrayList<>(n);
for(int i = 0; i < n; i++)
{
list.add(input.nextInt());
}
, где ваш конструктор будет:
public Polinom(List<Integer> koeficienti)
{
// Generally not best practice to just remember the list passed in; instead,
// make a *defensive copy* of it so this instance doesn't share the list with
// the caller. (Or accept an immutable list.)
this.koeficienti = new ArrayList<Integer>(koeficienti);
}
или , напишите вашконструктор такой, что он ожидает массив:
public Polinom(int[] entries)
{
this.koeficienti = new ArrayList<Integer>(entries.length);
for (int entry : entries) {
this.koeficienti.add(entry);
}
}
Вам могут пригодиться следующие официальные руководства по Java: